Yireo_Webp2 icon indicating copy to clipboard operation
Yireo_Webp2 copied to clipboard

How to convert for all the product images?

Open MagePsycho opened this issue 2 years ago • 3 comments

When I disable the cache and visit the pages, the jpg, png to webp conversion works fine.

But how to convert for all the products at once via CLI? Am I missing the documentation?

MagePsycho avatar Apr 12 '22 17:04 MagePsycho

There is a CLI of the NextGenImages, with commands like next-gen-images:convert. But this is more for testing and not so good for performance. If you would try to convert all images for a catalog of 10k products, then this could easily lead to 40k images. Either this would give PHP timeouts, or it would lead to the Magento bootstrap being kickstarted numerous times. Either way, PHP is not the best processing tool for this.

I would recommend to use a simple find plus convert (part of the Linux distro of Imagick) instead: find . -type f -name \*.jpg | while read IMAGE do; convert $IMAGE ${IMAGE/.jpg/.webp}; done. Or something.

jissereitsma avatar Apr 12 '22 18:04 jissereitsma

There is a CLI of the NextGenImages, with commands like next-gen-images:convert. But this is more for testing and not so good for performance. If you would try to convert all images for a catalog of 10k products, then this could easily lead to 40k images. Either this would give PHP timeouts, or it would lead to the Magento bootstrap being kickstarted numerous times. Either way, PHP is not the best processing tool for this.

I would recommend to use a simple find plus convert (part of the Linux distro of Imagick) instead: find . -type f -name \*.jpg | while read IMAGE do; convert $IMAGE ${IMAGE/.jpg/.webp}; done. Or something.

Thanks. Well noted.

What about using some cache-warmer tool that loops over all the links from sitemap.xml?

MagePsycho avatar Apr 12 '22 18:04 MagePsycho

Such a cache warmer would simply visit the pages and if those pages would contain the WebP picture tag, while there would be source images (like WebP) in that picture tag that are not existing yet, then those source images would simply be created.

jissereitsma avatar Apr 16 '22 13:04 jissereitsma