andz Posted May 23, 2009 Share Posted May 23, 2009 Is there a way to resize all images being uploaded on the server? im talking about .jpg, .gif, .bmp, .png, and other image extensions I have a script that converts only jpg gif and png but not sure if what's the problem of it because it only resizes 1 out of 5 images being uploaded. im also using that script to create thumbnails here's my function to create thumbnails and resize image function scaleJPG($filename, $targetw, $targeth, $quality, $targetfilename, $crop) { if ($im = @imagecreatefromjpeg($filename)) { $w = imagesx($im); $h = imagesy($im); $sc = 1; if ($w > $targetw){ $sc = $targetw/$w; } if ($h > $targeth/$sc){ $sc = $targeth/$h; } if (!$crop){ $result = imagecreatetruecolor($targetw, $targeth); $grey = imagecolorallocate($result, 0xf1, 0xef, 0xea); imagefill($result, 0, 0, $grey); imagecopyresampled($result, $im, ($targetw - $w*$sc)/2, ($targeth - $h*$sc)/2, 0, 0, $w*$sc, $h*$sc, $w, $h); } else { $result = imagecreatetruecolor($w*$sc, $h*$sc); imagecopyresampled($result, $im, 0, 0, 0, 0, $w*$sc, $h*$sc, $w, $h); } imagejpeg($result, $targetfilename, $quality); } } i'm not sure if the system is exhausted to resize the imgae, most of the image size is around 3000x5000 pixels thanks Link to comment https://forums.phpfreaks.com/topic/159405-resizing-image/ Share on other sites More sharing options...
andz Posted May 23, 2009 Author Share Posted May 23, 2009 forgot to mention that the size of the thumbnail is (100x100) and the size of the resize image is (800x600) or is there any scripts or functions that will resize all of the uploaded images no matter what image extension they have Link to comment https://forums.phpfreaks.com/topic/159405-resizing-image/#findComment-840831 Share on other sites More sharing options...
Axeia Posted May 23, 2009 Share Posted May 23, 2009 Take a look here: http://us3.php.net/manual/en/book.image.php Plenty more than just jpeg available If that isn't enough yet there is also: http://nl3.php.net/imagick (well on some hosts.. not all) I think the problem would be with the code calling the function, or perhaps a timeout as converting a lot of images at the size is bound to lead to a timeout. Link to comment https://forums.phpfreaks.com/topic/159405-resizing-image/#findComment-840836 Share on other sites More sharing options...
andz Posted May 23, 2009 Author Share Posted May 23, 2009 Yeah, that's what first comes to my mind, "TIMEOUT"... I'm also thinking that is it possible for this code to be use to convert all of the images inside the folder via cron jobs? If that's possible, not sure where to start that kind of solution. Link to comment https://forums.phpfreaks.com/topic/159405-resizing-image/#findComment-840839 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.