API Endpoint Access URL
https://api.pixlab.io/chop
Get Your API Key & Try CHOP Now ↗Description
CHOP API endpoint removes a selected region from an image and collapses the remaining parts to fill the removed area. Removes a region of an image and collapses the image to occupy the removed portion.
HTTP Methods
GET, POST
HTTP Parameters
Required
Fields | Type | Description |
---|---|---|
img |
URL | Input image URL. If uploading directly from your app, submit a multipart/form-data POST request. |
width |
Integer | Width of the chopped area. |
height |
Integer | Height of the chopped area. |
x |
Integer | X coordinates of the chopped area. |
y |
Integer | Y coordinates of the chopped area. |
key |
String | Your PixLab API Key ↗. Alternatively, embed your key in the WWW-Authenticate: HTTP header to omit this parameter. |
Tip:
If either height or width is missing (but not both), the available length is applied to the missing dimension.
Optional
Fields | Type | Description |
---|---|---|
blob |
Boolean | Returns JSON with output image link by default. Set to true to receive binary image data instead. |
POST Request Body
Use when submitting POST requests instead of GET.
Allowed Content-Type:
multipart/form-data
application/json
Use multipart/form-data
for direct image uploads (see REST API code samples). For JSON, ensure your image is already hosted. Call store to upload images before invoking this endpoint.
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 image ID. |
error |
String | Error message if status != 200. |
The API 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 the image binary data is returned directly. The JSON response structure is documented above.
Code Samples
import requests
def fetch_image_link():
try:
response = requests.get(
'https://api.pixlab.io/chop',
params={
'img': 'http://www.allaboutbirds.org/guide/PHOTO/LARGE/blue_jay_8.jpg',
'height': 20,
'x': 45,
'y': 72,
'key': 'PIXLAB_API_KEY'
},
timeout=10
)
response.raise_for_status()
data = response.json()
if data.get('status') == 200:
return data.get('link')
else:
print(f"Error: {data.get('error', 'Unknown error')}")
return None
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
return None
if __name__ == '__main__':
image_link = fetch_image_link()
if image_link:
print(f"Link to the pic: {image_link}")
fetch('https://api.pixlab.io/chop?img=http://www.allaboutbirds.org/guide/PHOTO/LARGE/blue_jay_8.jpg&height=20&x=45&y=72&key=PIXLAB_API_KEY')
.then(response => response.json())
.then(reply => {
if (reply.status !== 200) {
console.log(reply.error);
} else {
console.log("Link to the pic: " + reply.link);
}
})
.catch(error => console.error('Error:', error));
<?php
$params = [
'img' => 'http://www.allaboutbirds.org/guide/PHOTO/LARGE/blue_jay_8.jpg',
'height' => 20,
'x' => 45,
'y' => 72,
'key' => 'PIXLAB_API_KEY'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.pixlab.io/chop?' . 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)) {
die('Curl error: ' . curl_error($ch));
}
curl_close($ch);
$reply = json_decode($response, true);
if ($reply['status'] != 200) {
die($reply['error']);
}
echo "Link to the pic: " . $reply['link'];
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse('https://api.pixlab.io/chop')
params = {
'img' => 'http://www.allaboutbirds.org/guide/PHOTO/LARGE/blue_jay_8.jpg',
'height' => 20,
'x' => 45,
'y' => 72,
'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, border, charcoal, despeckle, deskew, edge, emboss, equalize, extent, flatten, gamma, flip