-
Notifications
You must be signed in to change notification settings - Fork 109
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
Don't overwrite original if optimized is larger #95
base: main
Are you sure you want to change the base?
Conversation
Thanks for contribution! But there is a trick about this: workers are responsible for checking if the size was reduced (check usage of |
Cool. Changed it so that it is now an optional parameter which is disabled by default. The main reason that I am adding this, is that some of the images that we were trying to optimize (all of which were pngs) were growing by a couple hundred to thousand bytes. |
don't use 1in in svg as it causes error when compared using ImageMagick
It is very strange that png images are growing in size, is it possible for you to share some of them? It looks like a bug. About the PR: I think it would be more meaningful to call the option |
Well crap, turns out that it was a miscommunication and instead of being a bug with the gem, it was a bug with how I was previously optimizing the images (before switching to image_optim). No one attached the commit SHA to the file compare so I misinterpreted the problem. Sorry about that. |
This pull request can still be useful for someone using |
README.markdown
Outdated
@@ -234,6 +234,9 @@ end | |||
image_optim.optimize_images!(Dir['*.*']) | |||
|
|||
image_optim.optimize_images_data(datas) | |||
|
|||
# Pass options like the sanity check | |||
image_optim.optimize_images!(images, :always_replace => false) |
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.
This is a remainder of previous commits.
You've committed |
Hi Winston, I am sorry for long wait, are you willing to finish this PR? |
@@ -3,6 +3,7 @@ | |||
## unreleased | |||
|
|||
* Use quality `0..100` by default in lossy mode of pngquant worker [#77](https://github.com/toy/image_optim/issues/77) [@toy](https://github.com/toy) | |||
* Don't do anything when "optimized" version is larger and `:skip_bigger => true` [@R167](https://github.com/R167) |
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.
Issue number is missing
Do we know if this is still an issue/desirable to fix/merge? |
I don't know if it is an issue, but if it is, it could be cool to have this functionality. |
@R167 It is still possible for jpegs to be overwritten with bigger file if original has exif rotation header, becomes bigger and is badly optimised |
Currently, the original image gets overwritten if the optimized version is larger (happens in some cases). Changing it so that only the smaller image is preserved when
optimize_image!
is called.