How to not generate webp when it's larger in size from the origional jpg #6
-
I'll start by saying what a great plugin, I just discovered it, and it seems that I'll be having a lot of fun with it. When I upload a new image, everything runs as expected, but in some images in some sizes (thumbnail for example) the generated webp file is larger in size than the original thumbnail file. Does the plugin handle this situation at all or maybe I missed a setting somewhere? I could provide examples and my settings and theme setup, but it would be extensive and a bit out of topic, if not specifically requested. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 4 replies
-
Usually WebP clones have much smaller file-sizes, you have an exception. If your image is JPEG, for converting JPEG images to WebP, you have two choices:
Then regenerate thumbnails for that image and see if it helps. Make sure to hard refresh the browser because previous WebP image can still be in the browser cache. Please let me know if that helps and what you did. |
Beta Was this translation helpful? Give feedback.
-
I will try, if it is possible, to configure Apache not to serve WebP Clones larger than cloned JPEG images. |
Beta Was this translation helpful? Give feedback.
-
Next version will have more options to select WebP compression quality when cloning and converting JPEG to WebP images.
Sites subscribed to plugin updates will be first to get next version when released. |
Beta Was this translation helpful? Give feedback.
-
You may find some useful settings of JPEG to WebP compression quality in version 1.10.3 |
Beta Was this translation helpful? Give feedback.
-
Yet another way: If you replace LINE RewriteCond %{DOCUMENT_ROOT}%1\.%2.webp -f WITH RewriteCond %{DOCUMENT_ROOT}%1\.%2 -f
RewriteCond %{DOCUMENT_ROOT}%1\.%2.webp -f
RewriteCond expr "filesize('%{DOCUMENT_ROOT}%1\.%2') gt filesize('%{DOCUMENT_ROOT}%1\.%2.webp')" YOU WILL GET YOUR SERVER CONFIGURED TO SKIP SERVING WebP CLONES LARGER THAN JPEG ORIGINALS. # BEGIN Warp-iMagick - First line of .htaccess file.
# Transparently serve WebP images instead of JPEG/PNG to WebP enabled browsers.
<IfModule mod_mime.c>
AddType image/webp .webp
</IfModule>
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_URI} (?i)(.*)\.(jpe?g|png)$
RewriteCond %{DOCUMENT_ROOT}%1\.%2 -f
RewriteCond %{DOCUMENT_ROOT}%1\.%2.webp -f
RewriteCond expr "filesize('%{DOCUMENT_ROOT}%1\.%2') gt filesize('%{DOCUMENT_ROOT}%1\.%2.webp')"
RewriteRule .+ %1\.%2\.webp [T=image/webp,E=webp:1,L]
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_webp
</IfModule>
</IfModule>
# END Warp-iMagick INSTEAD OF DEFAULT APACHE CONFIGURATION BLOCK # BEGIN Warp-iMagick - First line of .htaccess file.
# Transparently serve WebP images instead of JPEG/PNG to WebP enabled browsers.
<IfModule mod_mime.c>
AddType image/webp .webp
</IfModule>
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_URI} (?i)(.*)\.(jpe?g|png)$
RewriteCond %{DOCUMENT_ROOT}%1\.%2.webp -f
RewriteRule .+ %1\.%2\.webp [T=image/webp,E=webp:1,L]
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_webp
</IfModule>
</IfModule>
# END Warp-iMagick |
Beta Was this translation helpful? Give feedback.
-
Have you tried or decided to use modified Apache rules (above)? |
Beta Was this translation helpful? Give feedback.
Usually WebP clones have much smaller file-sizes, you have an exception.
If your image is JPEG, for converting JPEG images to WebP, you have two choices: