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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Shashank SrivastavaRank #1,097 · 1.7K reputationPosted Jun 26, 2014, 8:24 PM EDT
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);
?>