Articles > Development
Printer Friendly Version
Views: 7686

PHP imagecreatefromjpeg fails due to memory limit.

Last Updated: 1/11/09

If you are writing scripts in php using the imagecreatefromjpeg function and your scripts fail, either with a memory error or with no error, than this info may help you.

First, create a php script and run the function "phpinfo(); ". This will tell you what the memory limit is set for on your server. Second, use the formula below to figure out the largest dimensions that the server can handle. Then write your script to analyze the dimensions of the photo before you process it. This will help reduce errors.

Num bytes = Width * Height * Bytes per pixel * Overhead



Keywords: php imagecreatefromjpeg dimension limit memory error large file fails abort script