So I'm writing an upload script for images. Once the image is uploaded and copied to a directory, it then resizes the image and makes it less than 500px wide/tall. After getting the code to actually run for the first time it gave me an out of memory error. I found this gem after reading up on imagecreatefromjpeg on the PHP site.
It calculates the amount of memory needed for creating an image-resource out of and image-file. According to this code I need just over 30MB. The image that I uploaded is 1.5MB. Is this right? I mean seriously, 30+MB to process a single image of 1.5MB? I know that other scripts do this with half that, and probably even less. How can I figure out what is using up the memory?
$imageInfo = GetImageSize($imageFilename);
$memoryNeeded = Round(($imageInfo * $imageInfo * $imageInfo['bits'] * $imageInfo['channels'] / 8 + Pow(2, 16)) * 1.65);
I'll post some code if needed. Any thoughts? Thanks!