Skip to content

Commit

Permalink
Merge branch 'master' of github.com:shssoichiro/oxipng
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Holmer committed Apr 4, 2016
2 parents dbae0f7 + 1d87140 commit 0b7f40a
Show file tree
Hide file tree
Showing 92 changed files with 1,766 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
**Version 0.3.0 (unreleased)**
- Support interlaced images
- Allow converting between progressive and interlaced images
- Fix a bug that would cause oxipng to crash on very small images

**Version 0.2.2**
- Limit number of threads to 1.5x number of cores
- Significantly improve memory usage, especially with high optimization levels. ([#32](https://github.com/shssoichiro/oxipng/issues/32))
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Oxipng

[![Build Status](https://travis-ci.org/shssoichiro/oxipng.svg)](https://travis-ci.org/shssoichiro/oxipng)
[![Build Status](https://travis-ci.org/shssoichiro/oxipng.svg?branch=master)](https://travis-ci.org/shssoichiro/oxipng)
[![Version](https://img.shields.io/crates/v/oxipng.svg)](https://crates.io/crates/oxipng)
[![License](https://img.shields.io/crates/l/oxipng.svg)](https://github.com/shssoichiro/oxipng/blob/master/LICENSE)

Expand Down Expand Up @@ -66,7 +66,7 @@ More advanced options can be found by running `oxipng -h`.

## History

Oxipng began as a completely rewrite of the OptiPNG project,
Oxipng began as a complete rewrite of the OptiPNG project,
which is assumed to be dead as no commit has been made to it since March 2014.
The name has been changed to avoid confusion and potential legal issues.

Expand Down
7 changes: 5 additions & 2 deletions src/deflate/deflate.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use libz_sys;
use libc::c_int;
use std::cmp::max;

/// Decompress a data stream using the DEFLATE algorithm
pub fn inflate(data: &[u8]) -> Result<Vec<u8>, String> {
Expand All @@ -25,10 +26,12 @@ pub fn deflate(data: &[u8], zc: u8, zm: u8, zs: u8, zw: u8) -> Result<Vec<u8>, S
zw as c_int,
zm as c_int,
zs as c_int);
let mut output = Vec::with_capacity(data.len() / 20);
// Compressed input should be smaller than decompressed, so allocate less than data.len()
// However, it needs a minimum capacity in order to handle very small images
let mut output = Vec::with_capacity(max(1024, data.len() / 20));
loop {
match stream.compress_vec(input.as_mut(), output.as_mut()) {
libz_sys::Z_OK => output.reserve(data.len() / 20),
libz_sys::Z_OK => output.reserve(max(1024, data.len() / 20)),
libz_sys::Z_STREAM_END => break,
c => return Err(format!("Error code on compress: {}", c)),
}
Expand Down
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,8 @@ pub fn optimize(filepath: &Path, opts: &Options) -> Result<(), String> {

if let Some(interlacing) = opts.interlace {
if png.change_interlacing(interlacing) {
png.ihdr_data.interlaced = interlacing;
something_changed = true;
if opts.verbosity == Some(1) {
report_reduction(&png);
}
}
}

Expand Down
Loading

0 comments on commit 0b7f40a

Please sign in to comment.