Code Monkey home page Code Monkey logo

graphicsmagick-rs's Introduction

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:

    features = ["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.

graphicsmagick-rs's People

Contributors

dependabot[bot] avatar irkill avatar jmjoy avatar mgrachev avatar myaats avatar nobodyxu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

graphicsmagick-rs's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.