Note that there are some explanatory texts on larger screens.

plurals
  1. POFatal error: Allowed memory size
    primarykey
    data
    text
    <p>I am getting a fatal error from my image resize script that takes jpegs and resizes them and then saves. The image I am uploading are not over the max upload limit (not ever close) and based on the error I am not close to the limit. </p> <p><strong>Am I missing something about how the memory is used and why it would fail randomly but work on images that are larger?</strong></p> <pre><code>Fatal error: Allowed memory size of 52428800 bytes exhausted (tried to allocate 15756 bytes) in /home/content/t/w/e/myserver/html/test/includes/resize_class.php on line 34 </code></pre> <p>I have a php.ini file in the same directory</p> <pre><code>memory_limit = 50M post_max_size = 100M file_uploads = On upload_max_filesize = 192M </code></pre> <p>LINE 34: <code>$this-&gt;image = imagecreatefromjpeg($filename);</code></p> <p>resize_calss.php: Also to note. The user is uploading up to 3 iamges at a time and I am looping through and using this class to resize and save the thumbs on my server <pre><code>/* * File: SimpleImage.php * Author: Simon Jarvis * Copyright: 2006 Simon Jarvis * Date: 08/11/06 * Link: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details: * http://www.gnu.org/licenses/gpl.html * */ class SimpleImage { var $image; var $image_type; function load($filename) { $image_info = getimagesize($filename); $this-&gt;image_type = $image_info[2]; if( $this-&gt;image_type == IMAGETYPE_JPEG ) { $this-&gt;image = imagecreatefromjpeg($filename); } elseif( $this-&gt;image_type == IMAGETYPE_GIF ) { $this-&gt;image = imagecreatefromgif($filename); } elseif( $this-&gt;image_type == IMAGETYPE_PNG ) { $this-&gt;image = imagecreatefrompng($filename); } } function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this-&gt;image,$filename,$compression); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this-&gt;image,$filename); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this-&gt;image,$filename); } if( $permissions != null) { chmod($filename,$permissions); } } function output($image_type=IMAGETYPE_JPEG) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this-&gt;image); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this-&gt;image); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this-&gt;image); } } function getWidth() { return imagesx($this-&gt;image); } function getHeight() { return imagesy($this-&gt;image); } function resizeToHeight($height) { $ratio = $height / $this-&gt;getHeight(); $width = $this-&gt;getWidth() * $ratio; $this-&gt;resize($width,$height); } function resizeToWidth($width) { $ratio = $width / $this-&gt;getWidth(); $height = $this-&gt;getheight() * $ratio; $this-&gt;resize($width,$height); } function scale($scale) { $width = $this-&gt;getWidth() * $scale/100; $height = $this-&gt;getheight() * $scale/100; $this-&gt;resize($width,$height); } function resize($width,$height) { $new_image = imagecreatetruecolor($width, $height); imagecopyresampled($new_image, $this-&gt;image, 0, 0, 0, 0, $width, $height, $this-&gt;getWidth(), $this-&gt;getHeight()); $this-&gt;image = $new_image; } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload