Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elixir-mogrify/mogrify
Image processing in Elixir (ImageMagick command line wrapper)
https://github.com/elixir-mogrify/mogrify
elixir imagemagick mogrify wrapper
Last synced: 8 days ago
JSON representation
Image processing in Elixir (ImageMagick command line wrapper)
- Host: GitHub
- URL: https://github.com/elixir-mogrify/mogrify
- Owner: elixir-mogrify
- License: mit
- Created: 2014-09-30T14:19:59.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-05-30T11:45:07.000Z (over 1 year ago)
- Last Synced: 2024-10-07T08:07:59.388Z (about 1 month ago)
- Topics: elixir, imagemagick, mogrify, wrapper
- Language: Elixir
- Homepage:
- Size: 258 KB
- Stars: 567
- Watchers: 10
- Forks: 65
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - An Elixir wrapper for ImageMagick command line. (Images)
- awesome-starred - elixir-mogrify/mogrify - Image processing in Elixir (ImageMagick command line wrapper) (elixir)
README
# Mogrify
[![Build Status](https://github.com/elixir-mogrify/mogrify/actions/workflows/ci.yml/badge.svg)](https://github.com/elixir-mogrify/mogrify/actions?query=workflow%3ACI)
[![Module Version](https://img.shields.io/hexpm/v/mogrify.svg)](https://hex.pm/packages/mogrify)
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/mogrify/)
[![Total Download](https://img.shields.io/hexpm/dt/mogrify.svg)](https://hex.pm/packages/mogrify)
[![License](https://img.shields.io/hexpm/l/mogrify.svg)](https://github.com/elixir-mogrify/mogrify/blob/master/LICENSE.md)
[![Last Updated](https://img.shields.io/github/last-commit/elixir-mogrify/mogrify.svg)](https://github.com/elixir-mogrify/mogrify/commits/master)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`:
```elixir
def deps do
{:mogrify, "~> 0.9.3"}
end
```## Configuration
Configure the ImageMagick executable paths (optional):
Configure `mogrify` command:
```elixir
config :mogrify, mogrify_command: [
path: "magick",
args: ["mogrify"]
]
```Configure `convert` command:
```elixir
config :mogrify, convert_command: [
path: "magick",
args: ["convert"]
]
```Configure `identify` command:
```elixir
config :mogrify, identify_command: [
path: "magick",
args: ["identify"]
]
```## Examples
Thumbnailing:
```elixir
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:
```elixir
import Mogrifyimage = open("input.jpg") |> format("png") |> save
IO.inspect(image) # => %Image{path: "/tmp/568550-input.png", ext: ".png", format: "png"}
```Getting info:
```elixir
import Mogrifyimage = open("input.jpg") |> verbose
IO.inspect(image) # => %Image{path: "input.jpg", ext: ".jpg", format: "jpeg", height: 292, width: 300}
```Getting reduced info in a "lighter" way (uses less memory):
```elixir
import Mogrifyinfo = identify("input.jpg")
IO.inspect(info) # => %{format: "jpeg", height: 292, width: 300}
```Using custom commands to create an image with markup:
```elixir
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(hello markup world))
|> create(path: ".")
```Plasma backgrounds:
```elixir
import Mogrify%Mogrify.Image{path: "test.png", ext: "png"}
|> custom("size", "280x280")
|> custom("seed", 10)
|> custom("plasma", "fractal")
```Creating new images: See [mogrify_draw](https://github.com/zamith/mogrify_draw) for an example of generating a new image from scratch.
## Changelog
See the [changelog](./CHANGELOG.md) for important release notes between Mogrify versions.
## Copyright and License
Copyright (c) 2014 Dmitry Vorotilin
Mogrify source code is licensed under the [MIT License](./LICENSE.md).