Problem: getimagesize() does not work for some URLs, especially ones that are redirecting.
I googled around and checked stackoverflow but to no avail.
Here’s what I see on my local machine:
var_dump(getimagesize('http://gan.doubleclick.net/gan_impression?lid=41000000015155731&pubid=21000000000506299&lsrc=17'));
> Array
(
[0] => 120
[1] => 90
[2] => 2
[3] => width="120" height="90"
[bits] => 8
[channels] => 3
[mime] => image/jpeg
)
and on my server:
var_dump(getimagesize('http://gan.doubleclick.net/gan_impression?lid=41000000015155731&pubid=21000000000506299&lsrc=17'));
> bool(false)
I tried other images and URLs, and they work fine. It’s this URL that is giving me a problem. I also tried the following (on my server), and this does work:
echo strlen(file_get_contents('http://gan.doubleclick.net/gan_impression?lid=41000000015155731&pubid=21000000000506299&lsrc=17'));
> 4829 // This number means it works
The error log has nothing, and there is no other hints I can tell. I’m guessing it’s something that needs to change in the php.ini
If
file_get_contentsworks then definitelyfopenwould workCurl would have been the best option since you are having permission issue but you can also use FastImage .. to read the image headers and get the information instead of having to save the whole file locally
Example
Output
Simple Demo