Jump to content

Help with thumbnail generation code


fraser5002

Recommended Posts

Hi i am using a script to upload an image and resize it twice first to create the large image and then again to create a thumbnail.  The large image is being created fine and is uploading ok.

 

I'm using the following code to then make the thumbnail but it does not appear to be working ( well nothing is in the thumbnail image folder i expect it to be anyways) can anyone see anything obvious that i am doing wrong ?

 

Many Thanks

 

 

	///////////////////////////  Create a Thumbnail of the Image ////////////////////////////////////

list($width, $height) = getimagesize($upload_image); // this is the large image which has apready been uploaded
$ratio = $height/$width;
if($ratio >= '1') // portret
{
$ht_tmb = 150;
$br_tmb = 150/$ratio;
}
else
{ // landscape
$ht_tmb = 150*$ratio;
$br_tmb = 150;
}
// create thumb
$source = imagecreatefromjpeg($upload_image); // The large image already uploaded
//--- resize uploaded file
$resize = imagecreatetruecolor($br_tmb, $ht_tmb);
imagecopyresized($resize, $source, 0, 0, 0, 0, $br_tmb, $ht_tmb, $width, $height);
imagejpeg($resize, "gallery_images/small/" .$filenamefd);
$image = imagecreatefromjpeg("gallery_images/small/" .$filenamefd);
imagejpeg($image, "gallery_images/small/" . $filenamefd);
// end of making thumb

/////////////////////////////////////////////////////////////////////////////////////////////////

Link to comment
https://forums.phpfreaks.com/topic/216279-help-with-thumbnail-generation-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.