Jump to content

thumbnail generating


rpsep2

Recommended Posts

hi guys, im trying to resize and save a thumbnail version of images uploaded to my site in a sub folder (thumbs).

 

I've currently got:

 

 

$image=imagecreatefromjpeg($filepath);

 

list($width, $height) = getimagesize($filepath);

 

$new_width = 200;

$new_height= 150;

 

$image_p=imagecreatetruecolor($new_width, $new_height);

 

imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

 

// Save the image

imagejpeg($image_p, '/thumbs'.$filepath);

 

// Free up memory

imagedestroy($image_p);

 

 

but it appears to do nothing, but it also doesn't return any errors?

could someone help me out please?

thanks!

Link to comment
Share on other sites

Except for filepath changes (to suite my folders) I ran your code - no problems ???

<?php
$filepath = "./images/mainframe.jpg" ;
$image=imagecreatefromjpeg($filepath);

list($width, $height) = getimagesize($filepath);

$new_width = 200;
$new_height= 150;

$image_p=imagecreatetruecolor($new_width, $new_height);

imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

// Save the image
imagejpeg($image_p,   './images/thumb.jpg');

// Free up memory
imagedestroy($image_p);

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.