setStructureFromMail($msgFolder, $msgNumber); $fileContent = $attachmentObj->getAttachment($part); $pic = @imagecreatefromstring($fileContent); if($pic !== FALSE) { header("Content-Type: ".$fileType); header("Content-Disposition: inline"); $width = imagesx($pic); $height = imagesy($pic); $twidth = 160; # width of the thumb 160 pixel $theight = $twidth * $height / $width; # calculate height $theight = $theight < 1 ? 1 : $theight; $thumb = imagecreatetruecolor ($twidth, $theight); imagecopyresized($thumb, $pic, 0, 0, 0, 0,$twidth, $theight, $width, $height); # resize image into thumb imagejpeg($thumb,"",75); # Thumbnail as JPEG } //------------------------------------------// ?>