Coder Social home page Coder Social logo

magick's Introduction

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)

magick's People

Contributors

quirkey avatar mrb avatar arkan avatar

Watchers

James Cloos avatar  avatar

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.