Google-chrome – Why does Google Chrome save a JPG image to WEBP instead

google-chromejpegwebp

I'm trying to save what appears to be a JPG image from Chrome and always end up downloading a WEBP image instead.

I'm on Chrome Version 80.0.3987.163 on macOS Catalina (10.15.4) and I'm trying to download a JPG image from a website. Even though the image URL clearly has a .jpg extension, when I hit CMD+S or right click the image and select Save image as... I'm presented with the file system dialog to save it and the format dropdown is set to Google's WEBP as shown here.

My guess is that they're using a JPG extension on an image which is actually a WEBP, but it's quite misleading. Is that possible? Is there a way to download the image as a JPG?

Best Answer

File extensions are quite irrelevant for HTTP: if the server says Content-Type: image/webp, then it's a WebP image, period. (Compare to how most websites don't use .html in their URLs anymore even though they serve HTML-based webpages.)

The original image uploaded to the website was an JPEG file; however, it is served to you through a "content delivery network" (Akamai in this case). The CDN's job is to host these files and reduce load on the website's real servers, but many CDNs provide various optimization features to save bandwidth for clients as well – this often includes re-compressing images, minifying JS/CSS files, and so on.

Akamai looks at the HTTP request's User-Agent header to guess what the best format supported by your browser would be (although, oddly, it ignores the Accept header) and automatically converts the image to WebP whenever it wants to. The URL remains the same, but the response's Content-Type header indicates the new format.

Other than installing a "User Agent spoofer" extension or trying a different browser, you could also copy the URL and use the curl or wget tools through Terminal to download it (macOS should have at least one of them built-in). The CDN will usually exempt "non-browser" tools from the webpification feature.

curl -Of https://mosaic03.ztat.net/vgs/media/catalog-lg/NI/12/2O/0H/NQ/12/NI122O0HN-Q12@9.jpg
Related Question