Hi Friends,
I want to edit/update image in php and also create thumbnail image in folder. I have done update image but not created thumbnail image in folder. So please tell me anyone how to update and create thumbnail image in PHP ?
Thanks.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Shashank SrivastavaPosted Jun 27, 2014, 12:24 AM
This example will let you save the image in half of its original size.
This new size of the image can be altered according to your need. Hope u'll find this helpful
// File and new size
$filename = 'test.jpg';
$percent = 0.5;
// Content type
header('Content-Type: image/jpeg');
// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;
// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// Output
imagejpeg($thumb);
?>