You are here: gdi question « All PHP « IT news, forums, messages
gdi question

Posted by steve on 10/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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация