Jump to content

WebP image generation, without Jpg


pepperoni

Recommended Posts

Hi guys,

So I'm trying to achieve all my product images to use webp format, AND not create other unnecessary formats like jpg.

I have tried two different things.

1. Having the 'Multiple image formats' Enabled in New & Experimental Features.

image.png.76b5f442da21b659c8f9c580c93afee2.png

and having chosen 'WebP' in Image Settings.

image.png.2fc17db448a60b7b4320b2201630cdf5.png

With this configuration I confirm we can achieve webp image generation but at the same time it generates same images in jpg format too! That it not desirable for me, as I won't use the jpg files and it increases the account file size.

 

2. The second thing I tried is have the 'Multiple image formats' Disabled in New & Experimental Features.

image.png.cc10c6574b70f3c63f24c0bc00c45260.png

This makes the Image settings look a bit different. So here is what I have, Use WebP for all images.

image.png.60c2b44d2a87ac30e6ccb16ae7db0be4.png

With this configuration, the system generates images only in one format. The funny thing is the format is weird. You get .jpg files but the images are not jpg encoded, they are webp encoded. Think of it as in the first option above you take a webp image and you just rename it to .jpg, ie my_image.webp -> my_image.jpg.

 

What I'm trying to do is just get webp images (not any other formats). Second configuration above is very close. If only the generated images had .webp instead of .jpg.

Can anyone point me in the right direction of what is the file responsible for the naming of the images? I can change the code myself.

 

If someone had achieved similar thing using first configuration, then that I'd be fine with it too.

Please shed some light if you know more.

many thanks

prestashop version 8.1.3

 

 

Edited by pepperoni (see edit history)
Link to comment
Share on other sites

  On 1/22/2024 at 2:32 PM, pepperoni said:

If an image is webp then it should have the webp mime.

Expand  

and it have that mime. Image extension is not important, prestashop by default save images with jpg extension but it really could be webp, png or avif.

I think you want fix something what is not broken because ther is no reason to change extension when mime is correct.

Link to comment
Share on other sites

  • 10 months later...
  On 1/22/2024 at 5:20 PM, endriu107 said:

Why?

Expand  

Because Google PageSpeed request .webp format and .jpg is a negative SEO.

And anyway the Mime remains Jpg, all this should be resolved, or at least it would be nice to understand where the file containing the Webp generation function is located, so that it can be repaired.

Edited by Luigi Donato (see edit history)
Link to comment
Share on other sites

As explained, you can use any extension you like, but no browser or search engine will read it. The only real information about the type of image to be displayed is the MIME type.

Test your site with pagespeed and you won't get any errors on the image format, even if the extension is .jpg, if your image is in WebP.

All CDNs that automatically transform images don't change the file extension at all, to avoid unnecessary processing and redirection errors, and yet it works perfectly.

It's like DPI on images, it doesn't matter on the web.

Link to comment
Share on other sites

  • 1 month later...

@Mediacom87 are you talking about the MIME type provided by the server through a `Content-Type` HTTP header?

In my case I configured my PrestaShop to use webp for all images, and I regenerated all thumbnails. But still, all images have the `.jpg` extension, and their `Content-Type` from the server is `image/jpeg`.

I also try to create a new product with new webp images but still the same. There is no indication any `webp` format has been used somewhere.

I tried to look at image tag both on front office and back office, they are all talking about JPG.

NB: I understand the point of the extension being useless since the MIME type can be forced from the HTML tag or from the server, just wondering about my case where there is no indication at all? Or there is a bit marker within the binary that makes the browser understanding it no matter the wrong MIME type from the HTTP header?

Edited by sneko (see edit history)
Link to comment
Share on other sites

  On 12/21/2024 at 10:27 AM, Luigi Donato said:

Because Google PageSpeed request .webp format and .jpg is a negative SEO.

Expand  

Do you know what is negative SEO? Usually its sending a competitor garbish links.
Not using Google's format, the one they (Google) pushes has nill influence on ranking.  

In theory, jpg load slower, but there are a lot of people using webp and the weight of those images is higher than a proper compressed jpg.

Edited by Nickz (see edit history)
Link to comment
Share on other sites

  On 2/10/2025 at 1:53 PM, sneko said:

@Mediacom87 are you talking about the MIME type provided by the server through a `Content-Type` HTTP header?

In my case I configured my PrestaShop to use webp for all images, and I regenerated all thumbnails. But still, all images have the `.jpg` extension, and their `Content-Type` from the server is `image/jpeg`.

I also try to create a new product with new webp images but still the same. There is no indication any `webp` format has been used somewhere.

I tried to look at image tag both on front office and back office, they are all talking about JPG.

NB: I understand the point of the extension being useless since the MIME type can be forced from the HTML tag or from the server, just wondering about my case where there is no indication at all? Or there is a bit marker within the binary that makes the browser understanding it no matter the wrong MIME type from the HTTP header?

Expand  

Answering to myself, and adding a few details over @endriu107's message.

Having a different extension was understandable to me but I thought the browser would respect the MIME type from the server (here, being `image/jpeg`). So to confirm my guess there is a type signature inside the file, I downloaded a generated file like a thumbnail and removed its extension (so no preview is done in the IDE). After opening it inside my IDE I can see on the first line `RIFF6��WEBPVP8X` which according to the format documentation https://developers.google.com/speed/webp/docs/riff_container proves it's a true WebP file.

If you have a doubt, just make this check :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...