I am trying to find image/pixel size for an image before I use it. I see the following warning for an image. Warning: getimagesize(http://farm4.hv-static.flickr.com/3052/2330936325_ea1ddf9e7d_m.jpg): failed to open stream: Connection timed out
Any idea how one can handle this? I checked the manual but didnt find any option.
getimagesize returns FALSE if retrieving is failed. you can disable warnings output if you don't want to see them by
error_reporting(0);
As its manual page says :
If accessing the filename image is impossible, or if it isn't a valid picture,
getimagesize()
will generate an error of levelE_WARNING
.
On read error,getimagesize()
will generate an error of levelE_NOTICE
.
There is not much you can do about that, except making sure the error message is not displayed to your users.
This can be done changing the display_errors
directive:
ini_set('display_errors', 'off');
at the beginning of your script.
Or using the @
operator, to silence the error :
$result = @getimagesize(...);
Note : this is generally not quite a good idea : you'll totally loose the indication that an error occured !
It's better to not display the error, but still have it logged...