diff --git a/Cargo.toml b/Cargo.toml index 083b2199..ffe36b42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "optipng" -version = "2.0.0-alpha.1" +name = "oxipng" +version = "1.0.0-alpha.1" authors = ["Joshua Holmer "] [dependencies] diff --git a/README.md b/README.md index ce943f4d..c5f3f310 100644 --- a/README.md +++ b/README.md @@ -1,62 +1,60 @@ -# OptiPNG-Next +# OxiPng ## Overview -OptiPNG-Next version 2 is a completely rewrite of the OptiPNG project, +OxiPng began as a completely rewrite of the OxiPng project, which is assumed to be dead as no commit has been made to it since 2013. +The name has been changed to avoid confusion and potential legal issues. -OptiPNG is a PNG compression optimizer. +OxiPng is a PNG compression optimizer. -In the typical use case, OptiPNG recompresses PNG image files +In the typical use case, OxiPng recompresses PNG image files losslessly, converts external formats (BMP, GIF, PNM and TIFF) to optimized PNG, and performs PNG integrity checks and corrections. -At the user's explicit request, OptiPNG is also capable to alter -image data or remove metadata. ## Building -Building OptiPNG-Next can be done using Rust 1.5.0 or greater with Cargo installed, as follows: +Building OxiPng can be done using the latest stable or nightly Rust with Cargo installed, as follows: ``` -git clone https://github.com/shssoichiro/optipng-next.git -cd optipng-next +git clone https://github.com/shssoichiro/oxipng.git +cd oxipng cargo build --release -cp target/release/optipng /usr/local/bin +cp target/release/oxipng /usr/local/bin ``` -Please note that zlib is a required build dependency. OptiPNG should work with any 1.x version of zlib, +Please note that zlib is a required build dependency. OxiPng should work with any 1.x version of zlib, but you are advised to use the latest version (currently 1.2.8) for security and bug fixes. ## Usage -OptiPNG-Next is a command-line utility. Basic usage looks similar to the following: +OxiPng is a command-line utility. Basic usage looks similar to the following: ``` -optipng -o4 -i 1 -strip all *.png +oxipng -o 4 -i 1 --strip *.png ``` The most commonly used options are as follows: -* Optimization: `-o1` through `-o6`, lower is faster, higher is better compression. -The default (`-o2`) is sufficiently fast on a modern CPU and provides 30-50% compression -gains over an unoptimized PNG. `-o4` is 6 times slower than `-o2` but can provide 5-10% -extra compression over `-o2`. Using any setting higher than `-o4` is generally unlikely +* Optimization: `-o 1` through `-o 6`, lower is faster, higher is better compression. +The default (`-o 2`) is sufficiently fast on a modern CPU and provides 30-50% compression +gains over an unoptimized PNG. `-o 4` is 6 times slower than `-o 2` but can provide 5-10% +extra compression over `-o 2`. Using any setting higher than `-o 4` is generally unlikely to give any extra compression gains and is not recommended. * Interlacing: `-i 1` will enable [Adam7](https://en.wikipedia.org/wiki/Adam7_algorithm) PNG interlacing on any images that are processed. `-i 0` will remove interlacing from all processed images. Not specifying either will keep the same interlacing state as the input image. Note: Interlacing can add 25-50% to the size of an optimized image. Only use it if you have a good reason. -* Strip: Used to remove metadata info from processed images. Generally used as `-strip all`. +* Strip: Used to remove metadata info from processed images. Used via `--strip` or `-s`. Can save a few kilobytes if you don't need the metadata. -More advanced options can be found in the man page or by running `optipng -h`. +More advanced options can be found by running `oxipng -h`. ## Changes -OptiPNG Next version 2 attempts to maintain functionality of the original OptiPNG as much as possible, -although command line usage may have changed (OptiPNG Next follows semantic versioning). +OxiPng attempts to maintain functionality of the original OxiPng as much as possible, +although command line usage may have changed (OxiPng follows semantic versioning). -As version 2 is in alpha, there are still some features that are missing. All features -that were available in the original will be implemented in OptiPNG version 2 before it moves into -beta. +As OxiPng is in alpha, there are still some features that are missing. All intended features +will be implemented in OxiPng before it moves into beta. ## Contributing @@ -68,5 +66,4 @@ are also welcome via GitHub. ## License -OptiPNG Next is open-source software, distributed under the MIT license. (Version 2 is a complete rewrite and shares no -code with the original OptiPNG, which is under the zlib license.) +OxiPng is open-source software, distributed under the MIT license. diff --git a/src/deflate/stream.rs b/src/deflate/stream.rs index 9c95023a..64108f26 100644 --- a/src/deflate/stream.rs +++ b/src/deflate/stream.rs @@ -1,7 +1,7 @@ // Raw un-exported bindings to libz for encoding/decoding // Copyright (c) 2014 Alex Crichton, MIT & Apache licenses // Originally from flate2 crate for miniz -// Modified for use in Optipng +// Modified for use in oxipng use std::marker; use std::mem; diff --git a/src/main.rs b/src/main.rs index 45ef3883..cd867ffc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -extern crate optipng; +extern crate oxipng; extern crate clap; extern crate regex; @@ -20,7 +20,7 @@ fn main() { strategies.insert(i); } - let default_opts = optipng::Options { + let default_opts = oxipng::Options { backup: false, out_file: PathBuf::new(), out_dir: None, @@ -45,8 +45,8 @@ fn main() { strip: false, }; - let matches = App::new("optipng") - .version("2.0.0-alpha.1") + let matches = App::new("oxipng") + .version("1.0.0-alpha.1") .author("Joshua Holmer ") .about("Losslessly improves compression of PNG files") .arg(Arg::with_name("files") @@ -194,14 +194,14 @@ fn main() { .help("Strip all metadata objects") .long("strip")) .after_help("Optimization levels: - -o0 => -zc3 -nz (0 or 1 trials) - -o1 => -zc9 (1 trial) - -o2 => -zc9 -zs0-3 -f0,5 (8 trials) - -o3 => -zc9 -zm8-9 -zs0-3 -f0,5 (16 trials) - -o4 => -zc9 -zm8-9 -zs0-3 -f0-5 (48 trials) - -o5 => -zc3-9 -zm8-9 -zs0-3 -f0-5 (192 trials) - -o6 => -zc1-9 -zm7-9 -zs0-3 -f0-5 (360 trials) - -o6 -zm1-9 => -zc1-9 -zm1-9 -zs0-3 -f0-5 (1080 trials) + -o 0 => --zc 3 --nz (0 or 1 trials) + -o 1 => --zc 9 (1 trial) + -o 2 => --zc 9 --zs 0-3 --f 0,5 (8 trials) + -o 3 => --zc 9 --zm 8-9 --zs 0-3 --f 0,5 (16 trials) + -o 4 => --zc 9 --zm 8-9 --zs 0-3 --f 0-5 (48 trials) + -o 5 => --zc 3-9 --zm 8-9 --zs 0-3 --f 0-5 (192 trials) + -o 6 => --zc 1-9 --zm 7-9 --zs 0-3 --f 0-5 (360 trials) + -o 6 --zm 1-9 => --zc 1-9 --zm 1-9 --zs 0-3 --f 0-5 (1080 trials) Exhaustive combinations such as \"-o6 -zm1-9\" are not generally recommended. These are very slow and generally provide no compression gain. @@ -228,7 +228,7 @@ fn main() { &mut opts); } -fn handle_optimization(inputs: Vec, opts: &mut optipng::Options) { +fn handle_optimization(inputs: Vec, opts: &mut oxipng::Options) { for input in inputs { if input.is_dir() { if opts.recursive { @@ -244,14 +244,14 @@ fn handle_optimization(inputs: Vec, opts: &mut optipng::Options) { } else { opts.out_file = input.clone(); } - match optipng::optimize(&input, opts) { + match oxipng::optimize(&input, opts) { Ok(_) => (), Err(x) => println!("{}", x), }; } } -fn parse_opts_into_struct(matches: &ArgMatches, opts: &mut optipng::Options) -> Result<(), String> { +fn parse_opts_into_struct(matches: &ArgMatches, opts: &mut oxipng::Options) -> Result<(), String> { match matches.value_of("optimization") { Some("0") => { opts.idat_recoding = false;