I have a PHP script that is used to resize images in a custom FTP folder for use on its website.
While slow resizing, the script completed correctly with all images in the past. However, recently a user uploaded an album of 21-megapixel JPEG images, and, as I already found, the script cannot convert the images, but does not produce any PHP errors. When I consulted with various logs, I found that several Apache processes were killed with Out Of Memory errors.
The functional part of the PHP script is essentially a for loop that iterates through my images on disk and calls a method that checks if a thumbnail exists and then does the following:
$image = new Imagick();
$image->readImage($target);
$image->thumbnailImage(1000, 0);
$image->writeImage(realpath($basedir)."/".rescale."/".$filename);
$image->clear();
$image->destroy();
The server has 512 MB of RAM, usually at least 360 MB + free.
PHP has a memory limit currently set at 96 MB, but I set it higher without any impact on the problem.
According to my estimates, a 21-megapixel image should occupy an 80 MB + area when uncompressed, and therefore I am puzzled by why RAM disappears so quickly if Image Magick objects are not deleted from memory.
- script, ?
RAM, ?