You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the purposes of input validation, I would like to know the dimensions of the input PNG. Oxipng has this information but doesn't seem to provide any way of accessing it. For my purposes, I only need the width and height but the whole IHDR chunk would be nice. The simplest way to expose this information would probably be to make the png module public. That would make it possible to access PngImage and write code similar to optimize_from_memory.
let deadline = Arc::new(Deadline::new(opts.timeout));let original_size = data.len();letmut png = PngData::from_slice(data, opts.fix_errors)?;// Inspect IHDR or any auxiliary chunklet ihdr = &png.raw.ihdr;if ihdr.width != 256 || ihdr.height != 256{// Invalid image size}// Run the optimizer on the decoded PNG.let optimized_output = optimize_png(&mut png, data, opts, deadline)?;
The text was updated successfully, but these errors were encountered:
indianakernick
changed the title
Feature request: expose the internal png module
Feature request: expose the internal png module (among other things)
Jan 6, 2021
@indianakernick It's actually possible to access PngData and other internals currently, by importing them from a hidden module: use oxipng::internal_tests::PngData
Note that this is obviously not part of the public api and could change or break in any release. It also doesn't include optimize_png, so you may not actually be able to do what you're wanting this way.
Alternatively, you could use the separate png crate (or similar) to read the header info of the png before deciding whether to pass it into to oxipng.
For the purposes of input validation, I would like to know the dimensions of the input PNG. Oxipng has this information but doesn't seem to provide any way of accessing it. For my purposes, I only need the width and height but the whole IHDR chunk would be nice. The simplest way to expose this information would probably be to make the
png
module public. That would make it possible to accessPngImage
and write code similar tooptimize_from_memory
.The text was updated successfully, but these errors were encountered: