gmex v0.1.0 Gmex

A simple wrapper for GraphicsMagick in Elixir.

Summary

Functions

Returns a keywords list with information about the image like width, height, size, format and quality

Opens image source

Apply a GraphicsMagick option to the given image

Saves the modified image

Functions

get_info(image)

Specs

get_info(Image) ::
  {:ok, [width: Integer.t, height: Integer.t, size: String.t, format: String.t, quality: Integer.t]} |
  {:error, String.t}

Returns a keywords list with information about the image like width, height, size, format and quality.

open(src_path)

Specs

open(String.t) :: Image | {:error, :enoent}

Opens image source.

Example

iex> Gmex.open( "test/images/blossom.jpg" )
{ :ok, [ "test/images/blossom.jpg" ] }

iex> Gmex.open( "non-existing.png" )
{ :error, :enoent }
option(image, option)

Specs

option(Image, Option) :: Image | {:error, any}

Apply a GraphicsMagick option to the given image.

Example

iex> Gmex.open( "test/images/blossom.jpg" )
iex> |> Gmex.option( :negate )
iex> |> Gmex.option( { :resize, 50, 50 } )
iex> |> Gmex.option( :strip )
iex> |> Gmex.option( { :format, "jpg" } )
{ :ok, [ "test/images/blossom.jpg", "-negate", "-resize", "50x50", "-strip", "-format", "jpg" ] }

List of available options:

OptionGraphicsMagick
:plus_adjoin+adjoin
:adjoin-adjoin
{ :blur, radius, sigma }-blur radiusxsigma
{ :blur, radius }-blur radius
{ :crop, width, height, x_offset, y_offset }-crop widthxheight+x_offset+y_offset
{ :crop, width, height }-crop widthxheight
{ :edge, edge }-edge edge
{ :extent, width, height, x_offset, y_offset }-extent widthxheight+x_offset+y_offset
{ :extent, width, height }-extent widthxheight
flatten-flatten
{ :fill, color }-fill color
:strip-strip
:flip-flip
{ :format, format }-format format
{ :gravity, gravity }-gravity gravity
magnify-magnify
plus_matte+matte
matte-matte
negate-negate
{ :opaque, color }-opaque color
{ :quality, quality }-quality quality
{ :resize, width, height }-resize widthxheight
{ :resize, percents }-resize percents%
{ :rotate, degrees }-rotate degrees
{ :size, width, height }-size widthxheight
{ :size, width, height, offset }-size widthxheight+offset
{ :thumbnail, width, height }-thumbnail widthxheight
{ :thumbnail, percents }-thumbnail percents%
{ :transparent, color }-transparent color
{ :type, type }-type type
{ :custom, [ arg1, arg2, arg3... ] }arg1 arg2 arg3 …
save(image, dest_path)

Specs

save(Image, String.t) ::
  {:ok, nil} |
  {:error, String.t}

Saves the modified image

Example

iex> Gmex.open( "test/images/blossom.jpg" )
iex> |> Gmex.save( "newimage.jpg" )
{ :ok, nil }