peasy-image 0.2.2

Rust client for PeasyImage — image tools, glossary, and guides API
Documentation

peasy-image

crates.io docs.rs License: MIT crates.io GitHub stars

Async Rust client for the PeasyImage API — compress, resize, convert, and crop images. Built with reqwest, serde, and tokio.

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.

Table of Contents

Install

[dependencies]
peasy-image = "0.2.0"
tokio = { version = "1", features = ["full"] }

Or via cargo:

cargo add peasy-image

Quick Start

use peasy_image::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();

    // List available image tools
    let tools = client.list_tools(&Default::default()).await?;
    for tool in &tools.results {
        println!("{}: {}", tool.name, tool.description);
    }

    Ok(())
}

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
use peasy_image::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();

    // Retrieve the image compression tool and inspect its capabilities
    let tool = client.get_tool("compress-image").await?;
    println!("Tool: {}", tool.name);              // Image compression tool name
    println!("Description: {}", tool.description); // How compression works

    // List all available image tools with pagination
    let opts = peasy_image::ListOptions {
        page: Some(1),
        limit: Some(20),
        ..Default::default()
    };
    let tools = client.list_tools(&opts).await?;
    println!("Total image tools available: {}", tools.count);

    Ok(())
}

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
use peasy_image::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();

    // Browse the image glossary for digital media terminology
    let glossary = client.list_glossary(&peasy_image::ListOptions {
        search: Some("webp".into()), // Search for modern image format concepts
        ..Default::default()
    }).await?;
    for term in &glossary.results {
        println!("{}: {}", term.term, term.definition);
    }

    // Read a guide on choosing the right image format
    let guide = client.get_guide("image-format-comparison").await?;
    println!("Guide: {} (Level: {})", guide.title, guide.audience_level);

    Ok(())
}

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.

use peasy_image::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();

    // Search across all image content — tools, glossary, guides, and formats
    let results = client.search("convert webp", Some(20)).await?;
    println!("Found {} tools, {} glossary terms, {} guides",
        results.results.tools.len(),
        results.results.glossary.len(),
        results.results.guides.len(),
    );

    // Discover format conversion paths — what can PNG convert to?
    let conversions = client.list_conversions(&peasy_image::ListConversionsOptions {
        source: Some("png".into()), // Find all formats PNG can be converted to
        ..Default::default()
    }).await?;
    for c in &conversions.results {
        println!("{} -> {}", c.source_format, c.target_format);
    }

    Ok(())
}

Learn more: REST API Docs · All Image Tools

API Client

The client wraps the PeasyImage REST API with strongly-typed Rust structs using serde deserialization.

use peasy_image::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    // Or with a custom base URL:
    // let client = Client::with_base_url("https://custom.example.com");

    // List tools with filters
    let opts = peasy_image::ListOptions {
        page: Some(1),
        limit: Some(10),
        search: Some("resize".into()),
        ..Default::default()
    };
    let tools = client.list_tools(&opts).await?;

    // Get a specific tool
    let tool = client.get_tool("image-resize").await?;
    println!("{}: {}", tool.name, tool.description);

    // Search across all content
    let results = client.search("resize", Some(20)).await?;
    println!("Found {} tools", results.results.tools.len());

    // Browse the glossary
    let glossary = client.list_glossary(&peasy_image::ListOptions {
        search: Some("jpeg".into()),
        ..Default::default()
    }).await?;
    for term in &glossary.results {
        println!("{}: {}", term.term, term.definition);
    }

    // Discover guides
    let guides = client.list_guides(&peasy_image::ListGuidesOptions {
        category: Some("images".into()),
        ..Default::default()
    }).await?;
    for guide in &guides.results {
        println!("{} ({})", guide.title, guide.audience_level);
    }

    // List format conversions
    let conversions = client.list_conversions(&peasy_image::ListConversionsOptions {
        source: Some("png".into()),
        ..Default::default()
    }).await?;

    Ok(())
}

Available Methods

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

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
Ruby peasy-image gem install peasy-image

Peasy Developer Tools

Part of the Peasy Tools open-source developer ecosystem.

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

License

MIT