View Full Version : Is getimagesize efficient??

07-09-2010, 06:44 AM
Please excuse if similar issue has been posted earlier.

I want to check if a remote image exists or not.
say if url is http://example/image.png
and no image exists there, then...??

Earlier I was using @getimagesize function, but later on found this comment saying that it makes server slow for on large images.


I don't know if the solution mentioned in that comment is correct rather efficient?

Is there any other efficient, fast, small solution for this?

Thanks in advance...

07-09-2010, 01:49 PM
No, not really. Anything with images will be somewhat inefficient. You could instead just verify that the file exists and has a valid extension for images like .jpg but that won't guarantee the file is valid. It would work in most cases though.

07-09-2010, 02:41 PM
The @ is inefficient. You should suppress errors via your php.ini instead.

07-09-2010, 08:15 PM
True, but that will suppress all errors: for this sort of test, sometimes you must suppress that to avoid a warning if it fails.

Also, the efficiency lost from the @ compared to the time it takes to process getimagesize() would be insignificant.