Image to Image HTTP API Examples

These examples demonstrate common Image to Image API workflows via HTTP API.

You can run the examples below with the displayed API credentials. Update the input URLs and filenames as needed.


Basic examples

PNG file to JPEG file

curl -f -s -S \
  -u 'demo:demo' \
  -o logo.jpg \
  -F file=@logo.png \
  -F input_format=image \
  -F output_format=jpg \
  https://api.pdfcrowd.com/convert/24.04/

PNG url to JPEG file

curl -f -s -S \
  -u 'demo:demo' \
  -o logo.jpg \
  -F url=https://your-server.com/logo.png \
  -F input_format=image \
  -F output_format=jpg \
  https://api.pdfcrowd.com/convert/24.04/

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.

curl -f -s -S \
  -u 'demo:demo' \
  -o thumbnail.png \
  -F file=@scan.png \
  -F input_format=image \
  -F output_format=png \
  -F resize=400x400 \
  https://api.pdfcrowd.com/convert/24.04/

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:

curl -f -s -S \
  -u 'demo:demo' \
  -o square.png \
  -F file=@scan.png \
  -F input_format=image \
  -F output_format=png \
  -F canvas_background_color=EEF2F6 \
  -F canvas_height=400px \
  -F canvas_width=400px \
  -F dpi=96 \
  -F print_canvas_mode=fit \
  https://api.pdfcrowd.com/convert/24.04/

Transparent padding:

curl -f -s -S \
  -u 'demo:demo' \
  -o square-transparent.png \
  -F file=@scan.png \
  -F input_format=image \
  -F output_format=png \
  -F canvas_background_color=00000000 \
  -F canvas_height=400px \
  -F canvas_width=400px \
  -F dpi=96 \
  -F print_canvas_mode=fit \
  https://api.pdfcrowd.com/convert/24.04/

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:

curl -f -s -S \
  -u 'demo:demo' \
  -o chart.png \
  -F file=@scan.png \
  -F input_format=image \
  -F output_format=png \
  -F crop_area_height=384px \
  -F crop_area_width=1024px \
  -F crop_area_x=96px \
  -F crop_area_y=370px \
  -F dpi=96 \
  https://api.pdfcrowd.com/convert/24.04/

Remove a uniform border:

curl -f -s -S \
  -u 'demo:demo' \
  -o trimmed.png \
  -F file=@scan.png \
  -F input_format=image \
  -F output_format=png \
  -F remove_borders=true \
  https://api.pdfcrowd.com/convert/24.04/

Correct image rotation

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

curl -f -s -S \
  -u 'demo:demo' \
  -o upright.png \
  -F file=@scan-sideways.png \
  -F input_format=image \
  -F output_format=png \
  -F rotate=90 \
  https://api.pdfcrowd.com/convert/24.04/

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.

curl -f -s -S \
  -u 'demo:demo' \
  -o logo-background.jpg \
  -F file=@transparent-logo.png \
  -F input_format=image \
  -F output_format=jpg \
  -F canvas_background_color=EEF2F6 \
  https://api.pdfcrowd.com/convert/24.04/

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.

curl -f -s -S \
  -u 'demo:demo' \
  -o scan.webp \
  -F file=@scan.png \
  -F input_format=image \
  -F output_format=webp \
  https://api.pdfcrowd.com/convert/24.04/