I would like to resize images on server side to make thumbnail dynamicaly.
I’m using this code :
<?php
Header("Content-type: image/jpeg");
$img_src = $_GET['photo'];
$size = getimagesize($img_src);
$src_w = $size[0];
$src_h = $size[1];
$dst_w = 80;
$dst_h = 80;
$test_h = round(($dst_w / $src_w) * $src_h);
$test_w = round(($dst_h / $src_h) * $src_w);
if($src_w > $src_h) {
$x = $test_w;
$y = $dst_h;
} elseif($src_h > $src_w) {
$x = $dst_w;
$y = $test_h;
}
$img_new = imagecreatefromjpeg($img_src);
$img_mini = imagecreatetruecolor($x, $y);
imagecopyresampled($img_mini,$img_new,0,0,0,0,$x,$y,$src_w,$src_h);
imagejpeg($img_mini);
?>
But it didn’t work, and I can’t find why. There is no error, juste nothing appeared.
Can anybody help me ?
Thanks;
If you are getting a blank page, then either your script timed out or php memory limit was exceeded. Use
ini_setfunction to setmemory_limitandmax_execution_timebefore starting any gd function.Image manipulations take time as well as memory. So these configurations are important.