Expand description
§graphicsmagick-rs
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 clangBefore build, please check the GraphicsMagickWand-config is executable,
or specify the environment variable GRAPHICS_MAGICK_WAND_CONFIG correctly.
§Support
-
Support and tested GraphicsMagick version:
>= 1.3.20. -
If you want to use higher version functions, you should specify features in
Cargo.tomllike:features = ["v1_3_36"] -
GraphicsMagicksupports OpenMP if you are compiling with OpenMP-enabledcc, you can set the environment variableOMP_NUM_THREADSto limit the number of threads or setOMP_DISPLAY_ENV=TRUEto 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.
Re-exports§
pub use crate::error::Error;pub use crate::error::Result;pub use null_terminated_str;
Modules§
- error
- Crate level errors.
- types
- Binding of GraphicsMagick Types.
- wand
- Binding of GraphicsMagick Wand C API.
Structs§
Traits§
Functions§
- has_
initialized - Check if
initializehas called. - initialize
- Wrapper of
graphicsmagick_sys::InitializeMagick, call it before anygraphicsmagickaction. - max_rgb
- Wrapper of
graphicsmagick_sys::MaxRGBandgraphicsmagick_sys::MaxRGBDouble.