API Endpoint Access URL
https://api.pixlab.io/convert
Get Your API Key & Try CONVERT Now ↗Description
Convert static images to different formats like JPEG to PNG or BMP to TIFF while maintaining original dimensions. Use additional endpoints for resizing, cropping, thumbnails, and avatars. For GIF conversions, use the makegif endpoint. Convert a static image to another format such as JPEG to PNG, BMP to TIFF, etc. The output image will keep its original dimension. Call resize, crop, thumbnail, avatar, etc. if you want to adjust the width & height of the output image. For GIF conversion, please rely on makegif instead.
HTTP Methods
GET, POST
HTTP Parameters
Fields | Type | Description |
---|---|---|
img |
URL | Input image URL. If uploading directly from your app, submit a multipart/form-data POST request. |
export |
String | Output image format (JPEG , TIFF , BMP , PNG , etc.) |
key |
String | Your PixLab API Key ↗. Can also be embedded in WWW-Authenticate: header. |
Optional
Fields | Type | Description |
---|---|---|
blob |
Boolean | Returns image binary contents when true (default: JSON with output URL) |
background |
String | Background color (hex code like #cef45f ). Use tr or transparent for transparency. |
compression |
Integer | JPEG quality (0-100). JPEG conversion only. |
POST Request Body
Allowed Content-Types:
multipart/form-data
application/json
Use multipart/form-data
for direct image uploads (see samples). For JSON, the image must be pre-uploaded (use store endpoint first).
HTTP Response
The endpoint returns application/json
if the optional blob parameter is not set.
This API endpoint returns a JSON Object after each call only if the optional blob parameter is not set. Otherwise, the image binary contents are returned instead. The following are the JSON fields
returned in the response body:
Fields | Type | Description |
---|---|---|
status |
Integer | Status code 200 indicates success, any other code indicates failure. |
link |
URL | Link to the media output which is usually stored on the pixlab.xyz storage server unless you set your own S3 keys (refer to your dashboard ↗ on how to do that). |
id |
String | Unique media ID. |
error |
String | Error message if status != 200. |
Code Samples
import requests
from typing import Dict, Any
def convert_image_to_png(image_url: str, api_key: str) -> None:
"""Convert JPEG image to PNG with transparent background using PixLab API.
Args:
image_url: URL of the JPEG image to convert.
api_key: Your PixLab API key.
"""
try:
response = requests.get(
'https://api.pixlab.io/convert',
params={
'img': image_url,
'export': 'png',
'background': 'transparent',
'key': api_key
},
timeout=10
)
response.raise_for_status()
data: Dict[str, Any] = response.json()
if data.get('status') == 200:
print(f"PNG Image Link: {data['link']}")
else:
print(f"Error: {data.get('error', 'Unknown error occurred')}")
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
except ValueError as e:
print(f"Invalid JSON response: {e}")
# Example usage:
# convert_image_to_png(
# image_url='https://www.allaboutbirds.org/guide/PHOTO/LARGE/blue_jay_8.jpg',
# api_key='PIXLAB_API_KEY'
# )
fetch('https://api.pixlab.io/convert?img=https://www.allaboutbirds.org/guide/PHOTO/LARGE/blue_jay_8.jpg&export=png&background=tr&key=PIXLAB_API_KEY')
.then(response => response.json())
.then(reply => {
if (reply.status !== 200) {
console.log(reply.error);
} else {
console.log("Pic Link: " + reply.link);
}
})
.catch(error => console.error('Error:', error));
php
<?php
// Convert JPEG image to PNG with transparent background.
// https://pixlab.io/endpoints/convert for more info.
$params = [
'img' => 'https://www.allaboutbirds.org/guide/PHOTO/LARGE/blue_jay_8.jpg',
'export' => 'png',
'background' => 'tr',
'key' => 'PIXLAB_API_KEY'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.pixlab.io/convert?' . http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$reply = json_decode($response, true);
if ($reply['status'] != 200) {
echo $reply['error'];
} else {
echo "Pic Link: " . $reply['link'];
}
require 'net/http'
require 'uri'
require 'json'
# Convert JPEG image to PNG with transparent background.
# https://pixlab.io/endpoints/convert for more info.
uri = URI.parse('https://api.pixlab.io/convert')
params = {
'img' => 'https://www.allaboutbirds.org/guide/PHOTO/LARGE/blue_jay_8.jpg',
'export' => 'png',
'background' => 'tr',
'key' => 'PIXLAB_API_KEY'
}
uri.query = URI.encode_www_form(params)
response = Net::HTTP.get_response(uri)
reply = JSON.parse(response.body)
if reply['status'] != 200
puts reply['error']
else
puts "Pic Link: #{reply['link']}"
end
Similar API Endpoints
store, copy, delete, put, nsfw, sfw, ocr, facedetect, docscan, faceverify ↗, facelookup ↗, facemotion, screencapture, bg-remove, tagimg