-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Update oxipng to v9 [updated] #1396
Changes from all commits
e4322bc
1b24d2f
5649427
df7b622
42ef430
9db572e
e2514df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# OxiPNG | ||
|
||
- Source: <https://github.com/shssoichiro/oxipng> | ||
- Version: v3.0.0 | ||
- Version: v9.0.0 | ||
- License: MIT |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "oxipng", | ||
"scripts": { | ||
"build": "RUST_IMG=rustlang/rust@sha256:744aeea5a38f95aa7a96ec37269a65f0c6197a1cdd87d6534e12bb869141d807 ../build-rust.sh ./build.sh" | ||
"build": "RUST_IMG=rustlang/rust@sha256:5fd16a5576c22c8fdd5d659247755999e426c04de8dcf18a41ea446c5f253309 ../build-rust.sh ./build.sh" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# OxiPNG | ||
|
||
- Source: <https://github.com/shssoichiro/oxipng> | ||
- Version: v3.0.0 | ||
- Version: v9.0.0 | ||
- License: MIT |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# OxiPNG | ||
|
||
- Source: <https://github.com/shssoichiro/oxipng> | ||
- Version: v3.0.0 | ||
- Version: v9.0.0 | ||
- License: MIT |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
#[cfg(feature = "parallel")] | ||
pub use wasm_bindgen_rayon::init_thread_pool; | ||
|
||
use oxipng::AlphaOptim; | ||
use oxipng::{BitDepth, ColorType, Interlacing}; | ||
use wasm_bindgen::prelude::*; | ||
use wasm_bindgen::Clamped; | ||
|
||
#[wasm_bindgen] | ||
pub fn optimise(data: &[u8], level: u8, interlace: bool) -> Vec<u8> { | ||
pub fn optimise( | ||
data: Clamped<Vec<u8>>, | ||
width: u32, | ||
height: u32, | ||
level: u8, | ||
interlace: bool, | ||
) -> Vec<u8> { | ||
let mut options = oxipng::Options::from_preset(level); | ||
options.alphas.insert(AlphaOptim::Black); | ||
options.alphas.insert(AlphaOptim::White); | ||
options.alphas.insert(AlphaOptim::Up); | ||
options.alphas.insert(AlphaOptim::Down); | ||
options.alphas.insert(AlphaOptim::Left); | ||
options.alphas.insert(AlphaOptim::Right); | ||
options.interlace = Some(if interlace { 1 } else { 0 }); | ||
options.optimize_alpha = true; | ||
options.interlace = Some(if interlace { | ||
Interlacing::Adam7 | ||
} else { | ||
Interlacing::None | ||
}); | ||
|
||
options.deflate = oxipng::Deflaters::Libdeflater; | ||
oxipng::optimize_from_memory(data, &options).unwrap_throw() | ||
let raw = oxipng::RawImage::new(width, height, ColorType::RGBA, BitDepth::Eight, data.0) | ||
.unwrap_throw(); | ||
raw.create_optimized_png(&options).unwrap_throw() | ||
} |
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.
Oh I just saw that Oxipng now also offers Zopfli. Coo. We should expose that at some point.
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.
We absolutely should