CMS MADE SIMPLE FORGE

Gallery

 

[#7301] Check for memory exhaustion before creating thumbnails

avatar
Created By: Clarence Risher (sparr)
Date Submitted: 2011-12-04 18:08

Assigned To:
Resolution: None
State: Open
Summary:
Check for memory exhaustion before creating thumbnails
Detailed Description:
I've made the following modification to my Gallery.module.php to avoid my
gallery page dying when I accidentally upload images that are too large for PHP
to open without exhausting its memory. I don't know how to implement this
correctly, but someone around here must.

				case IMAGETYPE_JPEG:
					$imagedata = getimagesize($image);
					if($imagedata[0] * $imagedata[1] * 4 > 48*1024*1024) {					
echo "<!-- NOT creating thumbnail for " . $image . ", x: ".$imagedata[0]."
y: ".$imagedata[1]." --!>";
						return FALSE;
					} else {
						echo "<!-- creating thumbnail for " . $image . " --!>";
						$source = imagecreatefromjpeg($image);
					}
					break;

History

Updates

Updated: 2011-12-04 18:16
description: I've made the following modification to my Gallery.module.php to avoid my gallery page dying when I accidentally upload images that are too large for PHP to open without exhausting its memory. I don't know how to implement this correctly, but someone arou => I've made the following modification to my Gallery.module.php to avoid my gallery page dying when I accidentally upload images that are too large for PHP to open without exhausting its memory. I don't know how to implement this correctly, but someone arou
resolution_id: => 5