PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
for some reason the code below is not writing the image info to the destination file, I have been trying for hours to get it to work, I have check all the vars and they are all being send and all have values, I had it working yesterday, but for some reason I'm missing the spark.
function makeThumbnailImage($pathToSourceImage,$pathToThumbImage, $thumbHeight, $thumbWidth)
{
// get image type
$imageType = $this->imageis($pathToSourceImage);
if( $imageType == "jpg"){
// create output file
$src_img=imagecreatefromjpeg($pathToSourceImage);
// calutlate the size of out put file, maintaining aspect ratio
$thumbXY = $this->calcNewSize($imageWidth,$imageHeight,$thumbWidth,$thumbHeight);
$dst_img = @imagecreatetruecolor($thumbXY[0],$thumbXY[1]) or die("Unable to create thumbnail image stream!!<br>Image Name: $fileName");
// write image to Thumb file
imagejpeg($dst_img,$pathToThumbImage);
// remove image from ram
imagedestroy($dst_img);
imagedestroy($src_img);
}
}
// calutlate the size of out put file, maintaining aspect ratio
$thumbXY = $this->calcNewSize($imageWidth,$imageHeight,$thumbWidth,$thumbHeight);
$dst_img = @imagecreatetruecolor($thumbXY[0],$thumbXY[1]) or die("Unable to create thumbnail image stream!!<br>Image Name: $fileName");
// write image to Thumb file
imagejpeg($dst_img,$pathToThumbImage);
function makeThumbnailImage($pathToSourceImage,$pathToThumbImage, $thumbHeight, $thumbWidth)
{
// get image type
$imageType = $this->imageis($pathToSourceImage);
if( $imageType == "jpg"){
// get source image dimentions
$img_details = getimagesize($pathToSourceImage);
// calutlate the size of out put file, maintaining aspect ratio
$thumbXY = $this->calcNewSize($img_details[0],$img_details[1],$thumbWidth,$thumbHeight);
$dst_img= imagecreatetruecolor($thumbXY[0],$thumbXY[1]);
$src_img = imagecreatefromjpeg($pathToSourceImage);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumbXY[0],$thumbXY[1],$img_details[0],$img_details[1]);
// write image to Thumb file
imagejpeg($dst_img,$pathToThumbImage);
// remove image from ram
imagedestroy($dst_img);
imagedestroy($src_img);
}
}