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
https://forums.phpfreaks.com/topic/262342-thumbnail-generating/
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);

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.