0.0
The project is in a healthy, maintained state
Image processing library for Ruby — resize, crop, compress, convert between formats, and add watermarks. Uses ImageMagick/GraphicsMagick via system CLI.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

peasy-image

Gem Version License: MIT GitHub stars

Ruby client for the PeasyImage API — compress, resize, convert, and crop images. Zero dependencies beyond Ruby stdlib (Net::HTTP, JSON, URI).

Built from PeasyImage, a comprehensive image processing toolkit offering free online tools for compressing, resizing, converting, and cropping images across all major formats. The site includes in-depth guides on image optimization for the web, format comparisons between WebP, AVIF, PNG, and JPEG, plus a glossary covering concepts from color spaces to alpha channels to EXIF metadata.

Try the interactive tools at peasyimage.comCompress Image, Resize Image, Convert Image, Crop Image, and more.

peasy-image demo — image compress, resize, and convert tools in Ruby terminal

Table of Contents

  • Install
  • Quick Start
  • What You Can Do
    • Image Processing Operations
    • Browse Reference Content
    • Search and Discovery
  • API Client
    • Available Methods
  • Learn More About Image Tools
  • Also Available
  • Peasy Developer Tools
  • License

Install

gem install peasy-image

Or add to your Gemfile:

gem "peasy-image"

Quick Start

require "peasy_image"

client = PeasyImage::Client.new

# List available image tools
tools = client.list_tools
tools["results"].each do |tool|
  puts "#{tool["name"]}: #{tool["description"]}"
end

What You Can Do

Image Processing Operations

Digital images are stored in dozens of formats, each optimized for different use cases. JPEG uses lossy compression ideal for photographs, PNG supports lossless compression with alpha channel transparency, WebP (developed by Google) offers both lossy and lossless modes at 25-34% smaller file sizes than JPEG, and AVIF (based on the AV1 video codec) pushes compression efficiency even further. PeasyImage provides tools to compress, resize, convert, and crop images across all these formats.

Operation Slug Description
Compress Image compress-image Reduce file size while preserving visual quality
Resize Image resize-image Scale dimensions with aspect ratio preservation
Convert Image convert-image Transform between PNG, JPEG, WebP, AVIF, and more
Crop Image crop-image Extract rectangular regions from images

Image compression quality is typically measured using structural similarity (SSIM) or peak signal-to-noise ratio (PSNR) metrics that quantify visual degradation. At JPEG quality 85, most photographs show no perceptible difference from the original while achieving 10-15:1 compression ratios. WebP and AVIF consistently achieve the same visual quality at 25-50% smaller file sizes by using more sophisticated prediction and transform coding techniques than JPEG's DCT-based approach.

require "peasy_image"

client = PeasyImage::Client.new

# Retrieve the image compression tool and inspect its capabilities
tool = client.get_tool("compress-image")
puts "Tool: #{tool["name"]}"              # Image compression tool name
puts "Description: #{tool["description"]}" # How compression works

# List all available image tools with pagination
tools = client.list_tools(page: 1, limit: 20)
puts "Total image tools available: #{tools["count"]}"

Learn more: Compress Image Tool · How to Compress Images for Web · Image Format Comparison

Browse Reference Content

PeasyImage includes a detailed glossary of image processing and digital media terminology, plus educational guides on format selection and optimization workflows. The glossary covers concepts like WebP (Google's modern image format with superior compression), EXIF (Exchangeable Image File Format metadata embedded by cameras), lossy vs. lossless compression trade-offs, color spaces (sRGB, Adobe RGB, Display P3), and alpha channels for transparency support.

Term Description
WebP Google's modern image format — lossy and lossless modes
EXIF Exchangeable Image File Format — camera metadata standard
Lossy Compression Compression that discards data to achieve smaller files
Color Space Mathematical model defining the range of representable colors
Alpha Channel Transparency layer in PNG, WebP, and AVIF images

Modern image format selection involves balancing compression efficiency, browser support, and feature requirements. WebP typically produces files 25-34% smaller than equivalent JPEG images while supporting both lossy and lossless modes plus transparency. AVIF (based on the AV1 video codec) pushes compression even further — often 50% smaller than JPEG at equivalent visual quality — but encoding is significantly slower and browser support, while growing rapidly, is not yet universal across all platforms and devices.

require "peasy_image"

client = PeasyImage::Client.new

# Browse the image glossary for digital media terminology
glossary = client.list_glossary(search: "webp")
glossary["results"].each do |term|
  puts "#{term["term"]}: #{term["definition"]}"
end

# Read a guide on choosing the right image format
guide = client.get_guide("image-format-comparison")
puts "Guide: #{guide["title"]} (Level: #{guide["audience_level"]})"

Learn more: Image Glossary · Image Format Comparison · How to Compress Images for Web

Search and Discovery

The API supports full-text search across all content types — tools, glossary terms, guides, use cases, and format documentation. Search results are grouped by content type, making it easy to find the right tool or reference for any image processing workflow. Format conversion data covers the full matrix of source-to-target transformations, including feature constraints — converting from PNG to JPEG discards the alpha channel since JPEG does not support transparency, while converting to WebP preserves transparency with significantly smaller file sizes.

require "peasy_image"

client = PeasyImage::Client.new

# Search across all image content — tools, glossary, guides, and formats
results = client.search("convert webp")
puts "Found #{results["results"]["tools"].length} tools"
puts "Found #{results["results"]["glossary"].length} glossary terms"
puts "Found #{results["results"]["guides"].length} guides"

# Discover format conversion paths — what can PNG convert to?
conversions = client.list_conversions(source: "png")
conversions["results"].each do |c|
  puts "#{c["source_format"]} -> #{c["target_format"]}"
end

# Get detailed information about a specific image format
format = client.get_format("png")
puts "#{format["name"]} (#{format["extension"]}): #{format["mime_type"]}"
Format Compression Transparency Primary Use
JPEG Lossy No Photographs, web images
PNG Lossless Yes (alpha) Graphics, screenshots, icons
WebP Both Yes (alpha) Modern web, smaller than JPEG/PNG
AVIF Both Yes (alpha) Next-gen web, best compression ratio

Learn more: REST API Docs · All Image Tools · All Formats

API Client

The client wraps the PeasyImage REST API using only Ruby standard library — no external dependencies.

require "peasy_image"

client = PeasyImage::Client.new
# Or with a custom base URL:
# client = PeasyImage::Client.new(base_url: "https://custom.example.com")

# List tools with pagination and filters
tools = client.list_tools(page: 1, limit: 10, search: "resize")

# Get a specific tool by slug
tool = client.get_tool("image-resize")
puts "#{tool["name"]}: #{tool["description"]}"

# Search across all content
results = client.search("resize")
puts "Found #{results["results"]["tools"].length} tools"

# Browse the glossary
glossary = client.list_glossary(search: "jpeg")
glossary["results"].each do |term|
  puts "#{term["term"]}: #{term["definition"]}"
end

# Discover guides
guides = client.list_guides(category: "images")
guides["results"].each do |guide|
  puts "#{guide["title"]} (#{guide["audience_level"]})"
end

# List file format conversions
conversions = client.list_conversions(source: "png")

# Get format details
format = client.get_format("png")
puts "#{format["name"]} (#{format["extension"]}): #{format["mime_type"]}"

Available Methods

Method Description
list_tools List tools (paginated, filterable)
get_tool(slug) Get tool by slug
list_categories List tool categories
list_formats List file formats
get_format(slug) Get format by slug
list_conversions List format conversions
list_glossary List glossary terms
get_glossary_term(slug) Get glossary term
list_guides List guides
get_guide(slug) Get guide by slug
list_use_cases List use cases
search(query) Search across all content
list_sites List Peasy sites
openapi_spec Get OpenAPI specification

All list methods accept keyword arguments: page:, limit:, category:, search:.

Full API documentation at peasyimage.com/developers/. OpenAPI 3.1.0 spec: peasyimage.com/api/openapi.json.

Learn More About Image Tools

Also Available

Language Package Install
Python peasy-image pip install "peasy-image[all]"
TypeScript peasy-image npm install peasy-image
Go peasy-image-go go get github.com/peasytools/peasy-image-go
Rust peasy-image cargo add peasy-image

Peasy Developer Tools

Part of the Peasy Tools open-source developer ecosystem.

Package PyPI npm RubyGems Description
peasy-pdf PyPI npm Gem PDF merge, split, rotate, compress — peasypdf.com
peasy-image PyPI npm Gem Image resize, crop, convert, compress — peasyimage.com
peasy-audio PyPI npm Gem Audio trim, merge, convert, normalize — peasyaudio.com
peasy-video PyPI npm Gem Video trim, resize, thumbnails, GIF — peasyvideo.com
peasy-css PyPI npm Gem CSS minify, format, analyze — peasycss.com
peasy-compress PyPI npm Gem ZIP, TAR, gzip compression — peasytools.com
peasy-document PyPI npm Gem Markdown, HTML, CSV, JSON conversion — peasyformats.com
peasytext PyPI npm Gem Text case conversion, slugify, word count — peasytext.com

Embed Widget

Embed PeasyImage widgets on any website with peasy-image-embed:

<script src="https://cdn.jsdelivr.net/npm/peasy-image-embed@1/dist/embed.min.js"></script>
<div data-peasyimage="entity" data-slug="example"></div>

Zero dependencies · Shadow DOM · 4 themes (light/dark/sepia/auto) · Widget docs

License

MIT