API Endpoint Access URL
https://api.pixlab.io/border
Get Your API Key & Try BORDER Now ↗Description
Create custom borders for images with desired colors using the BORDER API endpoint. Ideal for developers and creators looking to enhance image aesthetics. Generate a border with a desired color for a given image.
HTTP Methods
GET, POST
HTTP Parameters
Required
Fields | Type | Description |
---|---|---|
img |
URL | Input image URL. If you want to upload your image directly from your app, then submit a multipart/form-data POST request. |
width |
Integer | The width of the border (Max value is set to 300). |
height |
Integer | The height of the border (Max value is set to 300). |
color |
String | A string representing the color for example: red , blue , yellow , etc or a color code like #fffeec, #e45cff, etc. If this field is missing, then the default color is set to gray . |
key |
String | Your PixLab API Key ↗. You can also embed your key in the WWW-Authenticate: HTTP header and omit this parameter if you want to. |
Tip:
If one of the height or width parameter is missing (but not both), then the available length is applied to the missing side.
Optional
Fields | Type | Description |
---|---|---|
blob |
Boolean | By default, this API endpoint return a JSON Object holding the link to the image output. But, if this parameter is set to true then the image binary contents is returned instead. |
POST Request Body
This section details the requirements for using a POST request instead of a simple GET request.
Allowed Content-Types:
multipart/form-data
application/json
To facilitate direct image uploads, utilize multipart/form-data
. Please consult the REST API code samples for a functional implementation. If you are using JSON, then your image must be already uploaded somewhere. Call store if you want to upload an image before invoking this endpoint.
HTTP Response
The BORDER endpoint returns application/json
if the optional blob parameter is not set.
This endpoint returns a JSON Object after each call unless the blob parameter is specified, in which case it returns the raw image binary. The response JSON contains the following fields:
Fields | Type | Description |
---|---|---|
status |
Integer | Status code 200 indicates success, any other code indicates failure. |
link |
URL | Link to the processed image stored on pixlab.xyz storage unless custom S3 keys are configured (see console.pixlab.io for configuration). |
id |
String | Unique image identifier. |
error |
String | Error description when status ≠ 200. |
Code Samples
import requests
API_URL = 'https://api.pixlab.io/border'
API_KEY = 'PIXLAB_API_KEY'
params = {
'img': 'http://www.allaboutbirds.org/guide/PHOTO/LARGE/blue_jay_8.jpg',
'width': 20,
'color': 'yellow',
'key': API_KEY
}
try:
response = requests.get(API_URL, params=params, timeout=10)
response.raise_for_status()
data = response.json()
if data.get('status') == 200:
print(f"Link to the pic: {data['link']}")
else:
print(data.get('error', 'Unknown error occurred'))
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
except ValueError:
print("Invalid JSON response")
except KeyError:
print("Missing expected data in response")
fetch('https://api.pixlab.io/border?img=http://www.allaboutbirds.org/guide/PHOTO/LARGE/blue_jay_8.jpg&width=20&color=yellow&key=PIXLAB_API_KEY')
.then(response => response.json())
.then(data => {
if (data.status !== 200) {
console.log(data.error);
} else {
console.log("Link to the pic: " + data.link);
}
})
.catch(error => console.error('Error:', error));
<?php
$params = [
'img' => 'http://www.allaboutbirds.org/guide/PHOTO/LARGE/blue_jay_8.jpg',
'width' => 20,
'color' => 'yellow',
'key' => 'PIXLAB_API_KEY'
];
$url = 'https://api.pixlab.io/border?' . http_build_query($params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
$reply = json_decode($response, true);
if ($reply['status'] != 200) {
echo $reply['error'];
} else {
echo "Link to the pic: " . $reply['link'];
}
require 'net/http'
require 'json'
uri = URI('https://api.pixlab.io/border')
params = {
img: 'http://www.allaboutbirds.org/guide/PHOTO/LARGE/blue_jay_8.jpg',
width: 20,
color: 'yellow',
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 "Link to the pic: #{reply['link']}"
end
Similar API Endpoints
noise, blur, motionblur, gaussianblur, radialblur, blackthreshold, broder3d, charcoal, chop, despeckle, deskew, edge, emboss, equalize, extent, flatten, gamma, flip