wp-media / imagify-plugin

Speed up your website with lighter images without losing quality.
https://imagify.io
73 stars 26 forks source link

WebP is not resized to defined size #521

Closed markonikolic985 closed 2 years ago

markonikolic985 commented 4 years ago

When using image resizing in Imagify, original image is resized to defined value, but WebP stays in original size (width/height).

To Reproduce

  1. Go to Imagify Settings and make sure Resizing and WebP creation options are active
  2. Add new Media (or optimize existing) - make sure it is larger in width (so it get resized)
  3. Check original image and WebP dimensions. WebP will not be resized.

Expected behavior

WebP should be resized as same as the original format image.

Screenshots

Screen Shot 2020-10-09 at 11 16 25 AM
joejoe04 commented 2 years ago

I have an update on this, as I believe there is a new issue that's been brought to our attention that seems like it is closely related.

This user is on the free Starter plan and noticed that in cases where an original image is larger than 2MB in file size, the WebP version of the -scaled image is not being created even though the -scaled JPG/PNG version is optimized:

I was able to recreate this and can see the original file size of the -scaled.jpg image:

image

Is different than it is after optimization:

image

So I think that when it comes to the -scaled.jpg.webp version, Imagify is using the original to both test whether it is under the 2MB threshold for free accounts and also when it's created (since the dimensions end up being the same as the original image).

https://secure.helpscout.net/conversation/1816476418/331742

tictag commented 2 years ago

Further to @joejoe04 comments above (I am the user he mentions), here are my own test results:

2022-03-24_19-58-41

In this case, both 'Resize [to 1024px]' and 'Create WebP' options are enabled on the Starter Plan.

Note that the scaled images (all 1024x575px and approximately the same file size e.g. ~150KB) are not actually being used for WebP conversion, instead the original images are used. The scaled images are tiny, and well under the 2MB max file size for the Starter Plan, but they all fail the WebP conversion with the same error. Note the file sizes mentioned in the error - these appear to correspond to the file sizes of the original images (red highlight).

The expected results are:

On resize, the original image should be of no consequence to WebP conversion - this file is now just a backup.

tommy83 commented 2 years ago

Plugin with 600,000+ active installs waiting 2 years for a solution also in paid version?

remyperona commented 2 years ago

Reproduce the issue ✅

I was able to reproduce the issue. The original image is resized, but the WebP image isn't.

Identify the root cause ✅

The root cause is in the maybe_resize() method of the Process class. What happens is the following:

Scope a solution ✅

A working solution is to check the dimensions using the file dimensions themselves instead of the dimensions stored in the database for the image.

Estimate the effort ✅

effort [XS]