Need help with magick?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

quirkey
210 Stars 32 Forks 82 Commits 12 Opened issues

Description

go (golang) wrapper around imagemagick

Services available

!
?

Need anything else?

Contributors list

# 42,129
Ruby
Shell
JavaScr...
libgit2
59 commits
# 113,041
Clojure
sass-mi...
Sass
Docker
11 commits
# 241,789
deseria...
gorilla
HTML
CSS
1 commit
# 571,793
Redis
HTML
C
sse
1 commit

magick

magick implements image manipulation routines based on the ImageMagick MagickCore C library in Go. It is an opinionated high level wrapper around the proven ImageMagick lib.

Why

ImageMagick is Magic

Though Go's stdlib includes utilities for working with images, ImageMagick is one of the industry standards, not only in its relative ease-of-use for simple operations (like thumbnailing) but also in it's smart anti-aliasing and other proven techniques. We wanted to utilize the fast and conccurent environment that Go provides with the known and reliable output of what we were already seeing with ImageMagick.

Simple, High-level Operations

There are other libraries that wrap ImageMagick or related libraries, but we were looking/aiming for something that had simple functions that handled the most common operations, that we wanted needed in our web applications: Thumbnailing (Resizing/Cropping), adding shadows, converting to jpg, etc.

Works with BLOBs

One of the major bottlenecks we saw in our previous image pipeline was the reading and writing from disk (IO). We wanted to build our new pipeline around the idea that images could be read and manipulated from memory (or non-disk storage i.e. a database). This allows an image to be transformed without ever touching disk.

Usage

With files:

image, err := magick.NewFromFile("input.png")
defer image.Destroy()
err = image.Resize("400x200")
err = image.Shadow("#F00", 255, 5, 2, 2)
err = image.FillBackgroundColor("#00F")
err = image.ToFile("output.jpg")

With BLOBs:

image, err := magick.NewFromBlob(a_byteslice, "png")
defer image.Destroy()
err = image.Resize("400x200")
err = image.Shadow("#F00", 255, 5, 2, 2)
err = image.FillBackgroundColor("#00F")
a_new_byteslice, err = image.ToBlob("jpg")

For full API see the API docs

Gotchas/Known Issues

magick has been thorougly tested and is memory-leak free as long as you always

Destroy()
MagickImage's after you no longer need them.

Internally, MagickCore can be used concurrently without issues, though weve observed crashes/issues with concurrent usage when ImageMagick is compiled with OpenMP on OS X (this happens to be the default with homebrew). Mileage may vary.

TODO

  • Text rendering
  • compositing two images

Dependencies

magick depends on ImageMagick and specifically the MagickCore C library. In most linux environments this is included in the ImageMagick-devel packages (e.g.

yum install ImageMagick-devel
or
sudo aptitude install ImageMagick-devel
).

More

Who

magick is written and maintained by Aaron Quint (@aq) and Mike Bernstein (@mrb_bk)

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.