12 unstable releases (5 breaking)

0.6.0 Mar 20, 2023
0.5.0 Oct 18, 2022
0.4.0 Sep 3, 2022
0.3.2 May 31, 2022
0.1.1 Apr 19, 2020

#164 in Images

Download history 85/week @ 2023-12-12 32/week @ 2023-12-19 23/week @ 2023-12-26 142/week @ 2024-01-09 118/week @ 2024-01-16 266/week @ 2024-01-23 220/week @ 2024-01-30 179/week @ 2024-02-06 179/week @ 2024-02-13 198/week @ 2024-02-20 163/week @ 2024-02-27 152/week @ 2024-03-05 173/week @ 2024-03-12 226/week @ 2024-03-19 252/week @ 2024-03-26

827 downloads per month

MIT license

345KB
5.5K SLoC

graphicsmagick-rs

Rustc Version Actions Crate API

GraphicsMagick-Logo

GraphicsMagick binding for Rust.

Requirement

Require graphicsmagick, libgraphicsmagick, clang and libclang.

In Deepin/Ubuntu/Debian, you can install these by:

sudo apt install graphicsmagick libgraphicsmagick1-dev
sudo apt install llvm-dev libclang-dev clang

Before build, please check the GraphicsMagickWand-config is executable, or specify the environment variable GRAPHICS_MAGICK_WAND_CONFIG correctly.

Support

  1. Support and tested GraphicsMagick version: >= 1.3.20.

  2. If you want to use higher version functions, you should specify features in Cargo.toml like:

    featuers = ["v1_3_36"]
    
  3. GraphicsMagick supports OpenMP if you are compiling with OpenMP-enabled cc, you can set the environment variable OMP_NUM_THREADS to limit the number of threads or set OMP_DISPLAY_ENV=TRUE to display the OpenMP info when running the application.

    Read http://www.graphicsmagick.org/OpenMP.html for details.

Example

Simple resize example:

use anyhow::Context;
use graphicsmagick::{initialize, types::FilterTypes, wand::MagickWand};
use std::path::PathBuf;

fn main() -> anyhow::Result<()> {
    // This function should be invoked in the primary (original) thread
    // of the application's process, and before starting any OpenMP
    // threads, as part of program initialization.
    initialize();

    let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
        .join("..")
        .join("meta")
        .join("GraphicsMagick-Logo.webp");
    let path = path.to_str().context("get image path failed")?;

    let mut mw = MagickWand::new();
    mw.read_image(path)?
        .resize_image(100, 100, FilterTypes::UndefinedFilter, 1.)?
        .write_image("/tmp/output.webp")?;

    Ok(())
}

License

MIT.

Dependencies

~1.1–4.5MB
~79K SLoC