API Endpoint Access URL
https://api.pixlab.io/emailfit
Get Your API Key & Try EMAILFIT Now ↗Description
Generate a 320x240px thumbnail optimized for emails with EMAILFIT, a simple wrapper around the thumbnail endpoint. Generate a 320x240px thumbnail optimized for use in emails. This API endpoint is a just wrapper around thumbnail with width & height set respectively to 320 and 240.
HTTP Methods
GET, POST
HTTP Parameters
Required
Fields | Type | Description |
---|---|---|
img |
URL | Input media URL. If you want to upload your image directly from your app, submit a multipart/form-data POST request. |
key |
String | Your PixLab API Key ↗. You can also embed your key in the WWW-Authenticate: HTTP header and omit this parameter. |
Optional
Fields | Type | Description |
---|---|---|
blob |
Boolean | By default, returns JSON with output image URL. Set to true to return raw binary media content instead. |
POST Request Body
Use when submitting POST requests instead of GET:
Allowed Content-Types:
multipart/form-data
application/json
Use multipart/form-data
for direct file uploads (see REST API code samples). For JSON, media must be pre-uploaded. Call store endpoint first to upload images before processing.
HTTP Response
Fields | Type | Description |
---|---|---|
status |
Integer | Status code 200 indicates success, any other code indicates failure. |
link |
URL | Link to the image 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. |
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.
Code Samples
import requests
def fetch_image_location(image_url: str, api_key: str) -> None:
try:
response = requests.get(
'https://api.pixlab.io/emailfit',
params={
'img': image_url,
'key': api_key
},
timeout=10
)
response.raise_for_status()
data = response.json()
if data['status'] != 200:
print(f"Error: {data.get('error', 'Unknown error')}")
else:
print(f"Pic location: {data['link']}")
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
except ValueError:
print("Invalid JSON response")
except KeyError:
print("Malformed API response")
if __name__ == "__main__":
fetch_image_location(
image_url='http://www.drodd.com/images15/nature31.jpg',
api_key='My_PIXLAB_API_KEY'
)
fetch('https://api.pixlab.io/emailfit?img=http://www.drodd.com/images15/nature31.jpg&key=My_PIXLAB_API_KEY')
.then(response => response.json())
.then(reply => {
if (reply.status !== 200) {
console.log(reply.error);
} else {
console.log("Pic location: " + reply.link);
}
})
.catch(error => console.error('Error:', error));
<?php
$params = [
'img' => 'http://www.drodd.com/images15/nature31.jpg',
'key' => 'My_PIXLAB_API_KEY'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.pixlab.io/emailfit?' . http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
$response = curl_exec($ch);
if (curl_errno($ch)) {
throw new RuntimeException('cURL error: ' . curl_error($ch));
}
curl_close($ch);
$reply = json_decode($response, true);
if ($reply['status'] != 200) {
echo $reply['error'];
} else {
echo "Pic location: " . $reply['link'];
}
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse('https://api.pixlab.io/emailfit')
params = {
'img' => 'http://www.drodd.com/images15/nature31.jpg',
'key' => 'My_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 location: #{reply['link']}"
end
Similar API Endpoints
scale, minify, magnify, crop, resize, smartresize, remap, resample, thumbnail, merge, composite, avatar, webfit, msgfit, favicon, screencapture