Available APIs:

Image Processing

Resize image

Resize an image to given dimensions.

ID: img_resize

args:
image - base64 encoded image
link - link to an image
width - width in pixels
height - height in pixels
quality - from 0 to 100 for JPEG output. Default is 75.
return - return result (img or base64). Default is img.
Method requires image or link parameter. If both specified, then "image" parameter is used.
If just one dimension is given, resize the other one proprotionally.
If none of dimensions are given, do nothing.
Response: image binary data / base64 encoded image

Crop image

Crop specified amount of pixels from each side of an image

ID: img_crop

args:
image - base64 encoded image
link - link to an image
crop - comma-separated list of numbers for top, right, bottom, left sides of an image
quality - from 0 to 100 for JPEG output. Default is 75.
return - return result (img or base64). Default is img.
Method requires image or link parameter. If both specified, then "image" parameter is used.
Response: image binary data / base64 encoded image

Convert image

Convert image to JPG/PNG/GIF

ID: img_convert

args:
image - base64 encoded image
link - link to an image
format (required) - jpg, png or gif
quality - from 0 to 100 for JPEG output. Default is 75.
return - return result (img or base64). Default is img.
Method requires image or link parameter. If both specified, then "image" parameter is used.
Response: image binary data / base64 encoded image

Add watermark

Add watermark to specified position with and ability to resize watermark.

ID: img_watermark

args:
image - base64 encoded image
link - link to an image
wm_image - base64 encoded watermark image
wm_link - link to an watermark image
x - horizontal shift of watermark image in pixels starting from top left corner
y - vertical shift of watermark image in pixels starting from top left corner
width - width of watermark image
height - height of watermark image
quality - from 0 to 100 for JPEG output. Default is 75.
return - return result (img or base64). Default is img.
Method requires image or link parameter. If both specified, then "image" parameter is used.
Method requires wm-image or wm-link parameter. If both specified, then "wm-image" parameter is used.
If just one dimension of watermark image is given, resize the other one proprotionally.
If none of dimensions of watermark image are given, do not resize.
Response: image binary data / base64 encoded image

Add borders

Add borders with specified width and color to each side of an image.

ID: img_border_add

args:
image - base64 encoded image
link - link to an image
color (required) - HEX color or "transparent"
borders - comma-separated list of widths in pixels to add to each side of an image (top, right, bottom, left)
quality - from 0 to 100 for JPEG output. Default is 75.
return - return result (img or base64). Default is img.
Method requires image or link parameter. If both specified, then "image" parameter is used.
Response: image binary data / base64 encoded image

Request Examples

How to perform an API call:

URL: https://api.apicat.online
Request: POST application/json
Required params: key, id
Method specific params: see method description
Examples:
curl -d '{"key":"your-api-key", "id":"img_resize", "args":{"link":"http://example.com/image.jpg", "width":500, "height":300}}' -H "Content-Type: application/json" -X POST https://api.apicat.online/api.php

Use -O to save output to a file. You can also use -o 'filename' to save an image under specific filename.
PHP:
// image URL
$link = 'http://example.com/image.jpg';

// POST parameters
$params = array('key' => 'your-api-key', 'id' => 'img_resize', 'args' => array('link' => $link, 'width' => 500, 'height' => 300));

// POST method
$postContext = stream_context_create([
'http' => [
'header' => "Content-type: application/json",
'method' => 'POST',
'content' => json_encode($params)
],
]);

// Get image data from the API
$data = file_get_contents('https://api.apicat.online/api.php', false, $postContext);

// $data contains resized image
// save it a file
file_put_contents('images/image-resized.jpg', $data);
NodeJS:
npm install --save superagent

var superagent = require('superagent');
var fs = require('fs');

// image URL
var link = 'http://example.com/image.jpg';

// POST parameters
var params = {'key' : 'your-api-key', 'id' : 'img_resize', 'args' : {'link' : link, 'width' : 500, 'height' : 300}};

// Get image data from the API
superagent.post('https://api.apicat.online/api.php')
.send(params)
.end(function(err, res) {
var data = res.body;

// data contains resized image
// save it to a file
fs.writeFileSync('images/image-resized.jpg', data);
});

HTTP Responses

Success:

Status 200 - image binary data / base64 encoded image will be sent in the response body.

Failure:

Status 400 - JSON object with an "error" field containing error description will be sent in the response body.