Reputation: 913
This is very confusing to me and I can't seem to find any information anywhere which may explain this.
I've a database of around 1,000 image URL's and I am doing a cURL header callback
curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, array($this, 'headerCallback'));
Which in it looks for the content-length of the image URL ...
if ($name === 'content-length' && (int) $value === $this->filesizecheck) {
curl_setopt($this->curl, CURLOPT_NOBODY, true);
}
filesizecheck
just simply checks the filesize of the already downloaded image on my server.
CURLOPT_NOBODY
setting means if the filesize on my server matches the content-length coming from the header, it instructs the system not to download the image body, and stop at the header.
My initial idea in implementing this was to check if the image within the image URL has changed -- and if so, download and replace the image. If not-- do the header check, and skip over it.
What's boggling me is that sometimes the exact same image URL returns either a 24-bit or 32-bit of the exact same image. This was something I was not expecting, and is obviously throwing my filesizecheck
off!
Here are the headers for the image url's if it hints at anything:
Array
(
[0] => Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
[1] => Accept-Encoding: gzip, deflate
[2] => Accept-Language: en-US,en;q=0.9
[3] => Connection: keep-alive
[4] => Host: /////
[5] => Upgrade-Insecure-Requests: 1
)
Now, this is only on one server/host I've experienced this with.
Has anyone ever encountered the exact same image URL returning either a 24 bit (example content-length
value: 397570
of one image) or a 32 bit image (content-length
value: 501502
) of the same image, why this is and is there anything I can do to resolve this strange issue?
Of course this is throwing off the entire system of doing a header check and downloading the image if it has "changed" -- sometimes it wants to download the 24 bit image, sometimes it wants to download the 32 bit image -- seems completely random as to when it returns a 24-bit or 32-bit image.
Visually -- there is no difference in the image.
Must I somehow get the values off both the 24-bit and 32-bit image for this to work? Does anyone know why a static image URL would return (seemingly randomly) either a 24-bit or 32-bit of the same image?
What would be the suggested way forward? Any tips or information would be greatly appreciated!
Upvotes: 2
Views: 87