I'm trying to create thumbnails with PHP on a Windows Apache server using the folowing code:
<?
$img = "test.jpg";
$w=200;
header("Content-type: image/jpeg");
$im = @imagecreatefromjpeg("$img");
list($width, $height, $type, $attr) = getimagesize("$img");
$h = $height * ($w/$width);
$dim = imagecreatetruecolor($w, $h);
imagecopyresized($dim, $im, 0, 0, 0, 0, $w, $h, $width, $height);
imagejpeg($dim, '', 85);
imagedestroy($dim);
imagedestroy($im);
?>
it works perfect on small images (600x450, 41.7K but on large images (2736x3645, 4.11M
it fails.
If I comment out the line "header("Content-type: image/jpeg");" I get the error:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2736 bytes) in D:\xampp\htdocs\thumb.php on line 6
What is the problem?