Crystal C bindings for MagickWand library
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
spec
src
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md v0.2.4 Jan 14, 2017
shard.yml

README.md

MagickWand for Crystal Build Status

Crystal C bindings for MagickWand library, an interface to use the ImageMagick image processing libraries - see www.imagemagick.org

NOTE: MagickWand is a quite large library, if you find something missing contact me

Requirements

  • libMagickWand must be installed
  • pkg-config must be available

Installation

  • Add this to your application's shard.yml:
dependencies:
  magickwand-crystal:
    github: blocknotes/magickwand-crystal

Usage

Get image info:

require "magickwand-crystal"
LibMagick.magickWandGenesis    # lib init
wand = LibMagick.newMagickWand # lib init
if LibMagick.magickReadImage( wand, "test.png" )
  puts LibMagick.magickGetImageWidth wand
  puts LibMagick.magickGetImageHeight wand
end
LibMagick.destroyMagickWand wand  # lib deinit
LibMagick.magickWandTerminus      # lib deinit

Scale image and save in Jpeg format:

require "magickwand-crystal"
# ... lib init ...
LibMagick.magickReadImage wand, "test.png"
LibMagick.magickScaleImage wand, 320, 240
LibMagick.magickWriteImage wand, "test2.jpg"
# ... lib deinit ...

Convert to grayscale:

require "magickwand-crystal"
# ... lib init ...
LibMagick.magickReadImage wand, "test.jpg"
LibMagick.magickTransformImageColorspace wand, LibMagick::ColorspaceType::GRAYColorspace
LibMagick.magickWriteImage wand, "grayscale.jpg"
# ... lib deinit ...

More examples

See examples folder. There is also an example to generate an image on the fly with Kemal.

Documentation

The functions mapped have the same names of the MagickWand C library but with the first letter in lowercase.

Example: MagickWandGenesis => LibMagick.magickWandGenesis

Notes

Based on ImageMagick 6.9.7-3 - try the branch im_7.0 for ImageMagick 7.0.x

The Crystal Magic Wand ! :)

Sounds funny but I hope you find it a useful piece of software.

Contributors