nlfiedler / magick-rust

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

Add support for image coalesce #104

Closed walterbm closed 1 year ago

walterbm commented 1 year ago

Add support for the ImageMagick coalesce operation (MagickCoalesceImages). Coalesce is useful when converting animated images (e.g. GIF to WebP) to remove GIF optimizations and reproduce the full image at each point in the animation sequence. This creates an image sequence that is much easier to modify in other formats.

I discovered the need for coalesce because it turns out that before ImageMagick 7.1.x coalesce was applied automatically when converting an animated GIF to WebP. That is no longer the case so an explicit call to coalesce is required to ensure operations on animated GIFs don't create frame artifacts like "dropouts".

MagickCoalesceImages does not modify the MagickWand instance that is passed in as an argument so to make the mutation work as expected this new coalesce method replaces the value of self.wand with the result from MagickCoalesceImages

nlfiedler commented 1 year ago

Excellent, thank you for figuring that out and adding the function.