-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Only resize an image if it results in a smaller image size #32787
Conversation
Current default behaviour (for the last 2 years at least, or more) has been that any background file that is 'not an SVG or a GIF' will be resized *and stored as a PNG*. When uploading a large compressed (e.g. webp or jpg) image this default results in huge (1 MB+) background images. This is counterproductive as the intent of this function is to reduce file size. With this change, only if the resulting image has a smaller file size than the original file, the new file is used. Signed-off-by: JelleV <3942301+jcjveraa@users.noreply.github.com>
Docstring was copy-pasted and not updated. Signed-off-by: JelleV <3942301+jcjveraa@users.noreply.github.com>
9e19a02
to
c9f94dd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found 12 potential problems in the proposed changes. Check the Files changed tab for more details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found 12 potential problems in the proposed changes. Check the Files changed tab for more details.
Realized after having a think about my previous commits that the intent of the original function was also to ensure images are stored in a progressively loading format. With these further changes, I think the original intern is captured more closely. Signed-off-by: JelleV <3942301+jcjveraa@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found 14 potential problems in the proposed changes. Check the Files changed tab for more details.
Is it OK, that I suggest here that switching to WEBP for all previews might be the best way to go? PS: WEBP has been around for many years now and is perfect for the purpose we're talking about here.. |
Hey @jcjveraa thank you for this PR. Could you address all the psalm issues first? |
Superseded by #36471 |
Seems to be more properly fixed in the other PR so will indeed drop this - good luck :)Verstuurd vanaf mijn iPhoneOp 1 mrt. 2023 om 09:55 heeft John Molakvoæ ***@***.***> het volgende geschreven:
Closed #32787.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@jcjveraa the other one was pretty close/inspired from this one. But it also had tests, so huge bonus ;) |
Made to fix issue 32779.
Current default behaviour (for the last 2 years at least, or more) has been that any background file that is 'not an SVG or a GIF'
will be resized and stored as a PNG. When uploading a large compressed (e.g. webp or jpg) image this default results in (relatively) huge (1 MB+) background images, as per the issue I raised, as it then recompresses this e.g. 151kb jpg file to a 1MB png file. This is counterproductive as (per the original comments in the code) the intent of this function is to reduce file size.
With this change, only if the resulting image has a smaller file size than the original file, the new file is used.
Signed-off-by: JelleV 3942301+jcjveraa@users.noreply.github.com