php createimage
Hello I wanting to resize uploaded jpgs and am using a sample code:
<?php
function resize_jpg($img,$w,$h){
$imagedata = getimagesize($img);
if ($w && ($imagedata[0] < $imagedata[1])) {
$w = ($h / $imagedata[1]) * $imagedata[0];
} else {
$h = ($w / $imagedata[0]) * $imagedata[1];
}
$im2 = ImageCreateTrueColor($w,$h);
$image = ImageCreateFromJpeg($img); //line 15
imagecopyResampled ($im2, $image, 0, 0, 0, 0, $w, $h, $imagedata[0], $imagedata[1]);
ImageJpeg($im2, $img, 100);
}
resize_jpg("img_1774.jpg",200,200);
?>
I get:
Fatal error: Allowed memory size of 8388608 bytes exhausted at (null):0 (tried to allocate 6816 bytes) in /srv/www/htdocs/whatswhere/test.php on line 15
I've tried many variations and can't figure out the problem, the file is 833.2kb. Is it some sort of php or apache config
Help or pointer much appreciated Richard
|