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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.