Skip to content

Commit

Permalink
Fix issue for interlacing images smaller than 4px
Browse files Browse the repository at this point in the history
Fixes #42
  • Loading branch information
Joshua Holmer committed May 26, 2016
1 parent aff99f2 commit 2659776
Show file tree
Hide file tree
Showing 8 changed files with 307 additions and 258 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
**Version 0.8.2**
- Fix issue where images smaller than 4px width would crash on interlacing ([#42](https://github.com/shssoichiro/oxipng/issues/42))

**Version 0.8.1**
- Minor optimizations
- Fix issue where interlaced images with certain widths would fail to optimize
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oxipng"
version = "0.8.1"
version = "0.8.2"
authors = ["Joshua Holmer <jholmer.in@gmail.com>"]
description = "A lossless PNG compression optimizer"
license = "MIT"
Expand Down
19 changes: 8 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ pub fn optimize(filepath: &Path, opts: &Options) -> Result<(), String> {
match copy(in_file,
in_file.with_extension(format!("bak.{}",
in_file.extension()
.unwrap()
.to_str()
.unwrap()))) {
.unwrap()
.to_str()
.unwrap()))) {
Ok(x) => x,
Err(_) => {
return Err(format!("Unable to write to backup file at {}",
Expand Down Expand Up @@ -222,9 +222,9 @@ pub fn optimize(filepath: &Path, opts: &Options) -> Result<(), String> {
match out_file.metadata() {
Ok(out_meta) => {
let readonly = metadata.permissions()
.readonly();
.readonly();
out_meta.permissions()
.set_readonly(readonly);
.set_readonly(readonly);
}
Err(_) => {
if opts.verbosity.is_some() {
Expand Down Expand Up @@ -388,12 +388,9 @@ fn optimize_png(mut png: &mut png::PngData, file_original_size: usize, opts: &Op
let filtered = filters.get(&trial.0).unwrap();
let best = best.clone();
scope.execute(move || {
let new_idat = deflate::deflate::deflate(filtered,
trial.1,
trial.2,
trial.3,
opts.window)
.unwrap();
let new_idat =
deflate::deflate::deflate(filtered, trial.1, trial.2, trial.3, opts.window)
.unwrap();

if opts.verbosity == Some(1) {
writeln!(&mut stderr(),
Expand Down
Loading

0 comments on commit 2659776

Please sign in to comment.