Skip to content

Add output format conversion (PNG, JPEG, WebP, GIF) #90

Open

Description

@cschanhniem

Feature Request

Currently squish resizes images but preserves the input format. When resizing images for different contexts (web, social media, documentation), users often need to convert formats alongside resizing.

Proposed API

# Convert to JPEG during resize
squish -o output.jpg --format jpeg input.png

# Auto-detect format from output file extension
squish -o output.webp input.jpg

# Control JPEG/WebP quality
squish -o output.jpg --format jpeg --quality 85 input.png

Rationale

The image crate (already a dependency via 0.25.x) has built-in support for encoding/decoding PNG, JPEG, WebP, and GIF. This means:

  1. No new heavyweight dependencies — image already handles format conversion
  2. The resize pipeline is already decoding into an image::DynamicImage before resizing, so encoding to a different format at the output stage is a natural extension
  3. Common use case: screenshot tools produce PNG, but users often want JPEG for smaller file sizes when sharing

Alternative

A simpler approach would be to infer the output format from the --output-file extension when provided, rather than requiring an explicit --format flag.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions