Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebP is not resized to defined size #521

Closed
markonikolic985 opened this issue Oct 9, 2020 · 4 comments · Fixed by #694
Closed

WebP is not resized to defined size #521

markonikolic985 opened this issue Oct 9, 2020 · 4 comments · Fixed by #694
Assignees
Labels
effort [XS] < 1 day of estimated development time module: convert webp optimization priority: medium Issues which are important, but no one will go out of business. type: bug
Milestone

Comments

@markonikolic985
Copy link
Contributor

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
Copy link
Contributor

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
Copy link

tictag commented Mar 24, 2022

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:

  • Scale / Optimise the image
  • Check if the scaled image is > 2MB
    • If so, die with error '2MB Starter Plan cap breached' (or similar)
    • If not, convert scaled image to WebP
  • Check if WebP image file size > scaled image file size
    • If so, ask user to accept or warn user

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

@tommy83
Copy link

tommy83 commented Sep 11, 2022

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

@GeekPress GeekPress added this to the 2.1 milestone Sep 13, 2022
@remyperona
Copy link
Contributor

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:

  • The original image is resized
  • The new dimensions are stored for the original image
  • When doing the WebP conversion, the method is checking the dimensions of the resized image instead of the original one, so it considers there is no resize needed
  • The WebP file is created from the original image dimensions

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]

@remyperona remyperona added effort [XS] < 1 day of estimated development time and removed needs: grooming labels Oct 18, 2022
@remyperona remyperona self-assigned this Oct 18, 2022
@remyperona remyperona mentioned this issue Dec 9, 2022
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort [XS] < 1 day of estimated development time module: convert webp optimization priority: medium Issues which are important, but no one will go out of business. type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants