note 54524 deleted from function.imagecreatefromjpeg by betz
| From: | betz@php.net | Date: | Thu, 07 Jul 2005 09:19:09 +0000 |
| Subject: | note 54524 deleted from function.imagecreatefromjpeg by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-91582@lists.php.net to get a copy of this message | ||
Note Submitter: Ragno_x
----
Hi, I used a script to change the size on a jpeg , everything
works fine when the jpeg is small. All I want to do is check if
the jpeg is too big then make it smaller.
here is my code:
list($width, $height) = getimagesize($filename);
$size = filesize($filename);
if($size > (1*1024*1024))
{ $percent = round((($size)/ (1*1024*1024)), 2);
// scale it so it is no more than 1 mb
print "percent is: ".$percent;
$new_width = $width * $percent;
$new_height = $height * $percent;
$image_p = imagecreatetruecolor($new_width, $new_height); // true color for best
quality
if($extension =="JPG" || $extension =="jpg")
{ $image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width , $new_height , $width, $height);
// Output
unlink("uploads/".$_GET['name']);
imagejpeg($image_p, "uploads/".$_GET['name'], 100);
}
}
When trying to resize the jpeg it shows an error like this:
<b>Fatal error</b>: Allowed memory size of 18874368 bytes exhausted (tried to allocate
3567 bytes) in <b>/home/transform.php</b> on line <b>23</b><br />
I don't know how to fix this, if anyone can help me. Thank you,