We help IT Professionals succeed at work.

Error 500 with large image

Richard Korts
Medium Priority
Last Modified: 2012-05-06
We have an application that runs OK on one server but is slow & sometimes does not end correctly.

We are trying to move it to another server, we get a 500 Server Error.

The application processes images, sometimes large images, depending upon the images the customer uploads.

My co-developer thinks it is because of php memory limit. I have put a php.ini into the server folder upping memory to 128MB. It still fails.

My co-developer did a simple script to test for failuse, it is in the code below.

You can try the test script at a server that fails (www.rkassoc.net/ybads/test.php. You will get a Server 500 error.

You can try it at a server where it works, www.rkassociates.com/ybads/test.php.

What is the problem?
$i_resized = imagecreatetruecolor(2825, 2620);

Open in new window

Watch Question


I do not see anything on the server that succeeds, just a white background. It is possible that it also fails on the "working" server.

Do a phpinfo() on both machines and compare them see what is different. Look in the error log (probably /var/log/apache2/error.log) and see if there are any messages.

Load the image into a graphics package and see what it reports (if anything)
Richard KortsBusiness Owner / Chief Developer


To bportlock:

When you say "Load the image into a graphics package" do you mean like Paint Shop Pro or Photoshop?. If so, the images I have been testing with were created that way.

This is a commercial web server (1 & 1), I do not think I have access to the log files you mentioned. I'll look & see.
"This is a commercial web server (1 & 1), I do not think I have access to the log files you mentioned. I'll look & see"

I think that they create a subfolder in your web space and put the errorlog in there, but that might be fasthosts rather than 1and1. I notice that the "faulty" server is the one at 1and1 and  they set a hard limit of 20M on PHP no matter what you set memory_limit to in php.ini.


Since this is a large graphic image it may be that the intermediate representation causes the server to run out of memory thus causing the internal error.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Hmm.. that link did not post correctly. I'll try it again

Richard KortsBusiness Owner / Chief Developer


To bportlock,

Do you know if Verio does that too?

We have another account with them. I tried the test & it failed. I loaded a php.ini with 128M memory limit & it still failed.

I'm sorry, I've never even heard of verio.

With GD functions, memory is usually the constraining factor but do check for other obvious problems. Make sure the file exists on both servers, make sure it is spelt the same way, make sure the path to the file is correct. These are all items that can cause the GD functions to crash.

You really need to see the error logs.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.