Error 500 with large image

Posted on 2009-02-12
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 ( You will get a Server 500 error.

You can try it at a server where it works,

What is the problem?

$i_resized = imagecreatetruecolor(2825, 2620);


Open in new window

Question by:Richard Korts
    LVL 34

    Expert Comment

    by:Beverley Portlock
    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)

    Author Comment

    by:Richard Korts
    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.
    LVL 34

    Accepted Solution

    "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.
    LVL 34

    Expert Comment

    by:Beverley Portlock
    Hmm.. that link did not post correctly. I'll try it again

    Author Comment

    by:Richard Korts
    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.
    LVL 34

    Expert Comment

    by:Beverley Portlock
    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.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now