All formats

MiniMagick

LanguageRuby
LicenseMIT
Repositorygithub.com/minimagick/minimagick
DocumentationREADME
Depends onImageMagick and Ghostscript
Read / writeyes (rasterized through Ghostscript) / yes (raster image wrapped in EPS)

MiniMagick builds and runs ImageMagick command lines. ImageMagick reads EPS by calling Ghostscript, crops to the bounding box, and returns a bitmap at the density you set before the input file. Without a density the output is 72 dpi, which looks blurry for logos.

Output is always raster. For vector conversions use Ghostscript or Inkscape.

Installation#

Shell
gem install mini_magick
sudo apt install imagemagick ghostscript   # or: brew install imagemagick ghostscript

If reading fails with “not authorized”, your ImageMagick policy.xml blocks the EPS coder; relax that policy line.

Basic usage: convert EPS to PNG#

Ruby
require "mini_magick"

MiniMagick.convert do |convert|
  convert.density(300)      # before the input file
  convert << "logo.eps"
  convert << "logo.png"     # keeps transparency where the EPS draws nothing
end

How to convert EPS to JPEG on a white background#

Ruby
MiniMagick.convert do |convert|
  convert.density(300)
  convert << "logo.eps"
  convert.background("white")
  convert.alpha("remove")
  convert.resize("1200x")   # 1200 px wide
  convert.quality(90)
  convert << "logo.jpg"
end

How to get the size of an EPS graphic#

Ruby
image = MiniMagick::Image.open("logo.eps")
puts "#{image.width} x #{image.height} pt"   # at 72 dpi, pixels = points

How to make a thumbnail#

Ruby
image = MiniMagick::Image.open("logo.eps")
image.format("png", 0, { density: "150" })
image.resize("256x256")
image.write("thumb.png")

How to save an image as EPS#

Ruby
MiniMagick.convert do |convert|
  convert << "photo.jpg"
  convert << "eps3:photo.eps"   # eps2, eps3, or ept for EPS with a TIFF preview
end

Tips#