Image Convert API

Convert WebP to PNG or PNG to WebP server-side — with optional background fill, quality control, and full alpha-channel support.


Get your API token

Create an account and subscribe ($9/month) to start using the API.

Endpoint

POST /api/image-convert

Send the image as a multipart/form-data upload. The response is the converted image binary.

Limits

  • Max file size: 100 MB
  • Max image dimensions: 10 000 × 10 000 px
  • Accepted input formats: WebP, PNG

Authentication

Include your API token in every request:

  • Query parameter: ?token=YOUR_TOKEN
  • Header: Authorization: Bearer YOUR_TOKEN

Parameters

Parameter Required Values Description
file Yes WebP or PNG file The image to convert. Must be a valid .webp or .png file.
to Yes png, webp Target output format.
bg No transparent (default), white, black, #rrggbb Background to fill behind transparent areas. Use a hex colour (e.g. #ff0000) for a custom colour. Ignored if the image has no transparency.
quality No default (default), small, medium, best WebP output quality. small = 50, medium = 75, best = 92. Only applies when to=webp; PNG is always lossless.

Response

On success the API returns the converted image as binary with the appropriate Content-Type header (image/png or image/webp) and a Content-Disposition: attachment header containing the output filename.

HTTP/1.1 200 OK
Content-Type: image/png
Content-Disposition: attachment; filename="photo.png"

<binary image data>

Error responses are JSON: {"error": "message"}.

Example Requests

WebP → PNG (transparent background preserved)
curl -X POST https://abesttools.com/api/image-convert \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F "[email protected]" \
  -F "to=png" \
  -o photo.png
PNG → WebP with white background and medium quality
curl -X POST https://abesttools.com/api/image-convert \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F "[email protected]" \
  -F "to=webp" \
  -F "bg=white" \
  -F "quality=medium" \
  -o photo.webp
WebP → PNG with custom background colour
curl -X POST https://abesttools.com/api/image-convert \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F "[email protected]" \
  -F "to=png" \
  -F "bg=#f5f5f5" \
  -o logo.png

Error Responses

HTTP Status Reason
401Missing or invalid API token.
403No active subscription.
422Missing file, unsupported format, file > 100 MB, or dimensions > 10 000×10 000 px.
500GD extension or WebP support not available on the server.

Live Tester

Log in to use the live tester.