nlfiedler / magick-rust

Rust bindings for ImageMagick
https://crates.io/crates/magick_rust
Apache License 2.0
246 stars 63 forks source link

Set interlace options #90

Closed jmadotgg closed 2 years ago

jmadotgg commented 2 years ago

Is it possible to set the interlace scheme? I only found this option in the source code:

use magick_rust::{MagickWand};
fn main {
   START.call_once(|| {
       magick_wand_genesis();
   });
   let mut wand = MagickWand::new();
   wand.read_image(image_path)?;
   wand.set_interlace_scheme(1)?;
}

What about magick input.jpg -interlace [SCHEME] output.jpg? Schemes:

Line
None
Plane
Partition
GIF
JPEG
PNG

I tried to use wand.set_option("interlace", "Plane"), but that didn't work either. Could you please tell what the u32 in set_interlace_scheme is supposed to do? They didn't mention that in their docs.

Thank you! :crab:

nlfiedler commented 2 years ago

Yes, sorry that the API is not easy to learn, as most of it is auto-generated. In this case, the interlace value has the type InterlaceType which is literally a uint in C. The values are defined as follows in the Rust bindings:

How did I figure that out? By cloning this repo, running cargo build and then finding the bindings.rs file and looking through that. Yes, not something I expect others to do themselves, but when you're short on time, it works. Sorry it took so long for me to respond. Hope that helps.

jmadotgg commented 2 years ago

Thank you @nlfiedler! No problem. Have a nice day!

nlfiedler commented 2 years ago

Glad to help.