GD - Invalid PNG file error using imagecreatefromstring()
I am creating a site that allows users to upload an ZIP file of PNG, JPG, and GIF images and then manipulates them. I first validate the headers to confirm that all of the files are one of the three. Then I use imagecreatefromstring() to convert the raw data into a GD image resource. This works for most images I have uploaded. But on some PNG files I get an error saying that it isn't the proper format. I am unsure as to were thi开发者_JAVA技巧s error is coming from.
The server is running the latest PHP 5 and Apache2 on Ubuntu 10.10 Maverick 64-bit.
Have you confirmed that these files are indeed in the proper format after you've unzipped them on the server? Also, what is the file size of these images? The imagecreatefromstring() function can use quite a bit of memory; maybe you're hitting a memory limit somewhere.
精彩评论