|  | Posted by steve on 06/13/32 11:26 
i'm creating thumbnails from images on the server's hard drive. the code works however i'm getting some anomolous results...which on a consistent
 basis, i suppose, are "features". when i have a script that outputs multiple
 thumbnails, some images are shown while others remain blank and are shown
 with the classic red "X" image place holder and it's alt text. in the code
 below, am i leaving any handles open or causing memory leaks that could
 result in this behavior? any input is appreciated...tia.
 
 ===========
 
 <?
 $withOutput     = false;
 require_once 'inc/head.inc.php';
 $ownerId        = $_REQUEST['ownerId'];
 $fileName       = $_REQUEST['fileName'];
 $maxSize        = $_REQUEST['maxSize'];
 $filePath       = $siteUserUploadBaseDirectory . $ownerId . '/';
 if ($fileName == '' || $ownerId == '')
 {
 $fileName     = $_REQUEST['altImage'];
 $filePath     = $siteBaseDirectory . 'images/';
 }
 if (!isSupportedImage($fileName))
 {
 $fileName     = isSupportedMedia($fileName) ? 'media.jpg' :
 'document.jpg';
 $filePath     = $siteBaseDirectory . 'images/';
 }
 $fileData       = @file_get_contents($filePath . $fileName);
 $originalImage  = @imagecreatefromstring($fileData);
 @list($imageWidth, $imageHeight, $imageType, $imageAttributes) =
 @getimagesize($filePath . $fileName);
 $newImageHeight = $imageWidth < $maxSize ? $imageHeight : ($imageHeight /
 $imageWidth) * $maxSize;
 $newImageWidth  = $imageWidth < $maxSize ? $imageWidth  : $maxSize;
 $thumbNail      = @imagecreatetruecolor($newImageWidth, $newImageHeight);
 @imagecopyresampled(
 $thumbNail,
 $originalImage,
 0,
 0,
 0,
 0,
 $newImageWidth,
 $newImageHeight,
 @imagesx($originalImage),
 @imagesy($originalImage)
 );
 @imagejpeg($thumbNail);
 @imagedestroy($thumbNail);
 @imagedestroy($originalImage);
 ?>
  Navigation: [Reply to this message] |