Imagecreatefrompng() - Connection was reset error

506 views Asked by At

I have installed a piece of code on a website, wich includes gd functions. After debugging I came to a conclusion that the

$src = imagecreatefrompng($s);

is causing the server to respond: "Connection was reset" Even if I change the code to:

$src = @imagecreatefrompng($s);

The same error occurs. I have checked the php version, checked if gd library is installed and enabled, but everything is ok. There is nothing in the error_log. Also, the file path is all right, the file exists, and other functions can access the file (like fopen or file_get_contents), so there is no problem with the rights.

Anyone has an idea?

Edit: The file is on a local server.

1

There are 1 answers

0
quickshiftin On BEST ANSWER

Hmm, if you can't access the server via command line you may have some headaches tracking this down. 2 things that come to mind:

  1. It's unlikely, yet possible libpng is not installed, or gd wasn't compiled w/ PNG support. Run phpinfo() from the browser and look for the gd section, you should see PNG support 'enabled' there.
  2. The image might not be a PNG image! I know it's wacky but these things can happen, just naming a file .png does not a PNG file make, haha. If you have ImageMagick you can use the identify program to check, here's a run from my laptop:

    $ identify ~/transparent-pixel.png ~/transparent-pixel.png PNG 1x1 1x1+0+0 8-bit DirectClass 2.79KB 0.010u 0:00.009

There are probly some other programs you can use to verify the image is indeed an PNG.

Lastly, I would suggest getting your script to work in a local environment that simulates the server, like a VM or similar. That should help you track down the issue on the server w/o quite as many headaches.