Image to Image Command line Examples

Use these command-line examples for common Image to Image tasks. See the CLI guide for installation, input and output handling, and diagnostics.

You can run the examples below without account setup. The CLI uses demo credentials unless you have configured your own API credentials. Update the input URLs and filenames as needed.

Commands use POSIX-shell syntax, as in Bash or Zsh, and save results in the current directory.

Basic examples

These commands save the result with --output. See Handle the Result for output choices and failure handling.

Convert a file

Upload an existing logo.png file.

image2image --output-format=jpg \
    --output logo.jpg \
    logo.png

Convert a URL

image2image --output-format=jpg \
    --output logo.jpg \
    https://your-server.com/logo.png

Read bytes from stdin

Read logo.png through stdin. Use the same - input for bytes piped from another program.

image2image --output-format=jpg \
    --output logo.jpg \
    - < logo.png

Transform the image

These examples use scan.png, a 1224 × 1584 pixel image with a chart and a uniform white border. Rotation uses scan-sideways.png; JPEG background replacement uses transparent-logo.png.

Resize an image

Fit scan.png within 400 × 400 pixels while preserving its aspect ratio. The result is a 309 × 400 pixel thumbnail.png. Use a square canvas below when you need an exact 400 × 400 result.

image2image --output-format=png \
    --resize=400x400 \
    --output thumbnail.png \
    scan.png

Create a square thumbnail

Fit the whole image onto a 400 × 400 pixel canvas with either a pale blue background or transparent padding. Set 96 DPI so the px canvas dimensions match output pixels. The transparent variant preserves the original image's white background; transparency applies to the added canvas area.

Solid padding

image2image --canvas-background-color=EEF2F6 \
    --canvas-height=400px \
    --canvas-width=400px \
    --dpi=96 \
    --output-format=png \
    --print-canvas-mode=fit \
    --output square.png \
    scan.png

Transparent padding

image2image --canvas-background-color=00000000 \
    --canvas-height=400px \
    --canvas-width=400px \
    --dpi=96 \
    --output-format=png \
    --print-canvas-mode=fit \
    --output square-transparent.png \
    scan.png

Crop or trim an image

Extract the chart from scan.png into chart.png, or remove the uniform outer border and save trimmed.png.

The chart starts 96 pixels from the left and 370 pixels from the top, and measures 1024 × 384 pixels. Set 96 DPI so the px crop coordinates match source image pixels. Adjust the region for your image. Automatic border removal works on solid-color borders; use an explicit crop for uneven scan edges.

Extract a selected region

image2image --crop-area-height=384px \
    --crop-area-width=1024px \
    --crop-area-x=96px \
    --crop-area-y=370px \
    --dpi=96 \
    --output-format=png \
    --output chart.png \
    scan.png

Remove a uniform border

image2image --output-format=png \
    --remove-borders \
    --output trimmed.png \
    scan.png

Correct image rotation

Rotate scan-sideways.png 90 degrees clockwise to restore the upright orientation, then save upright.png.

image2image --output-format=png \
    --rotate=90 \
    --output upright.png \
    scan-sideways.png

Replace transparency when creating a JPEG

Convert transparent-logo.png to logo-background.jpg with a pale blue background. JPEG cannot retain transparency, so choose the background color explicitly.

image2image --canvas-background-color=EEF2F6 \
    --output-format=jpg \
    --output logo-background.jpg \
    transparent-logo.png

Convert an image to WebP

Convert scan.png to scan.webp at its original pixel dimensions. WebP uses lossy compression here, which can reduce file size at the cost of fine detail. Compare the result with your source image before choosing it for web delivery.

image2image --output-format=webp \
    --output scan.webp \
    scan.png