Don't write larger file if moving from interlaced to non-interlaced
Closes #62
This commit is contained in:
parent
848a73723e
commit
6499933eab
2 changed files with 3 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
|||
**Version 0.15.0 (unreleased)**
|
||||
- [SEMVER_MINOR] Check images for correctness before writing result ([#60](https://github.com/shssoichiro/oxipng/issues/60))
|
||||
- Fix invalid output when reducing image to a different color type but file size does not improve ([#60](https://github.com/shssoichiro/oxipng/issues/60))
|
||||
- Don't write new file if moving from interlaced to non-interlaced if new file would be larger
|
||||
|
||||
**Version 0.14.4**
|
||||
- Fix bug when reducing RGBA to Indexed if image has 256 colors plus a background color
|
||||
|
|
|
|||
|
|
@ -526,8 +526,7 @@ fn optimize_png(png: &mut PngData,
|
|||
let filters: HashMap<u8, Vec<u8>> = filters_tmp.into_iter().collect();
|
||||
|
||||
let original_len = original_png.idat_data.len();
|
||||
let interlacing_changed = opts.interlace.is_some() &&
|
||||
opts.interlace != Some(original_png.ihdr_data.interlaced);
|
||||
let added_interlacing = opts.interlace == Some(1) && original_png.ihdr_data.interlaced == 0;
|
||||
|
||||
let best: Option<TrialWithData> = results.into_par_iter()
|
||||
.weight_max()
|
||||
|
|
@ -551,7 +550,7 @@ fn optimize_png(png: &mut PngData,
|
|||
.ok();
|
||||
}
|
||||
|
||||
if new_idat.len() < original_len || interlacing_changed || opts.force {
|
||||
if new_idat.len() < original_len || added_interlacing || opts.force {
|
||||
Some((trial.0, trial.1, trial.2, trial.3, new_idat))
|
||||
} else {
|
||||
None
|
||||
|
|
|
|||
Loading…
Reference in a new issue