Giter VIP home page Giter VIP logo

mogrify's Introduction

Mogrify

Build Status

An Elixir wrapper for ImageMagick command line.

Documentation: https://hexdocs.pm/mogrify/

Requirements

You must have ImageMagick installed of course.

Installation

Add this to your mix.exs file, then run mix do deps.get, deps.compile:

  {:mogrify, "~> 0.8.0"}

Configuration

Configure the ImageMagick executable paths (optional):

Configure mogrify command:

  config :mogrify, mogrify_command: [
    path: "mogrify",
    args: []
  ]

Configure convert command:

  config :mogrify, convert_command: [
    path: "convert",
    args: []
  ]

Examples

Thumbnailing:

  import Mogrify

  # This does operations on an original image:
  open("input.jpg") |> resize("100x100") |> save(in_place: true)

  # save/1 creates a copy of the file by default:
  image = open("input.jpg") |> resize("100x100") |> save
  IO.inspect(image) # => %Image{path: "/tmp/260199-input.jpg", ext: ".jpg", ...}

  # Resize to fill
  open("input.jpg") |> resize_to_fill("450x300") |> save

  # Resize to limit
  open("input.jpg") |> resize_to_limit("200x200") |> save

  # Extent
  open("input.jpg") |> extent("500x500") |> save

  # Gravity
  open("input.jpg") |> gravity("Center") |> save

Converting:

  import Mogrify

  image = open("input.jpg") |> format("png") |> save
  IO.inspect(image) # => %Image{path: "/tmp/568550-input.png", ext: ".png", format: "png"}

Getting info:

  import Mogrify

  image = open("input.jpg") |> verbose
  IO.inspect(image) # => %Image{path: "input.jpg", ext: ".jpg", format: "jpeg", height: 292, width: 300}

Using custom commands to create an image with markup:

  import Mogrify

  %Mogrify.Image{path: "test.png", ext: "png"}
  |> custom("size", "280x280")
  |> custom("background", "#000000")
  |> custom("gravity", "center")
  |> custom("fill", "white")
  |> custom("font", "DejaVu-Sans-Mono-Bold")
  |> custom("pango", ~S(<span foreground="yellow">hello markup world</span>))
  |> create(path: ".")

Plasma backgrounds:

  import Mogrify

  %Mogrify.Image{path: "test.png", ext: "png"}
  |> custom("size", "280x280")
  |> custom("seed", 10)
  |> custom("plasma", "fractal")

Creating new images: See mogrify_draw for an example of generating a new image from scratch.

Changelog

See the changelog for important release notes between Mogrify versions.

License

Mogrify source code is licensed under the MIT License.

mogrify's People

Contributors

talklittle avatar route avatar kpanic avatar gustavocaso avatar notdevinclark avatar zamith avatar rkmax avatar mguterl avatar kamilzielinski avatar kyasu1 avatar parallel588 avatar caldwellysr avatar markzsombor avatar nitsujw avatar amarantedaniel avatar connorrigby avatar augustorsouza 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.