nlfiedler / magick-rust

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

Add binding for MagickStripImage #89

Closed davidwilemski closed 2 years ago

davidwilemski commented 2 years ago

Per the API docs, this should strip all profiles and comments attached to the image. This can be useful for removing identifying information from an image (e.g. EXIF tags).

davidwilemski commented 2 years ago

I saw a comment that tests are not required given that most of this is a light wrapper. If there's a test pattern you'd prefer me to use, I can definitely add one.

FWIW I built a very simple program depending on this branch's version of magick_rust and verified that it stripped my image as expected:

use magick_rust::{MagickWand, magick_wand_genesis};
use std::sync::Once;

static START: Once = Once::new();

fn strip_image(path: &str) {
    let wand = MagickWand::new();
    wand.read_image(path).unwrap();
    wand.strip_image().unwrap();
    wand.write_image(&format!("new-{}", path)).unwrap();
}

fn main() {
    let mut args = std::env::args();

    // skip binary name
    args.next();

    // image file to strip
    let path = args.next().unwrap();

    strip_image(&path);
}
nlfiedler commented 2 years ago

Thanks, David. I think unit tests would be overkill for anything that is little more than a function call. If it were more complex, then I think it would be worthwhile. Of more value would be code examples, although we would need lots of them because there are so many ways to use ImageMagick.