NAV Open/Close menu
shell python php


Welcome to Imagify API! You can use the API to optimize and resize your images.

API Libraries

A few libraries are already available to interact with our API. If you write your own library, we would be very happy to link you on this doc. Please contact us.


You can directly install it with pip:

pip install imagify-python

You can also install it by cloning the Github Repo and doing a :

python install


You can direclty install it with composer:

composer install wp-media/imagify-php

You can also install it by cloning the Github Repo


To authorize, use this code:

# With shell, you can just pass the correct header with each request
curl ""
  -H "Authorization: token my_api_key"
from imagify import Imagify

imagify = Imagify('my_api_key')

$imagify = new Imagify\Optimizer('my_api_key');

Make sure to replace my_api_key with your API key.

Imagify uses API keys to allow access to the API. You can register for free to get an API key at our website.

Imagify expects for the API key to be included in all API requests to the server in a header that looks like the following:

Authorization: token your_api_key


Upload and Optimize an image

require ('class-imagify.php');

$imagify = new Imagify\Optimizer('my_api_key');
$param = array(
    "level"=> 'ultra',
    "resize"=> array("width"=> 50),
$image = '1.jpg';   

$imagify->optimize($image, $param);
from imagify import Imagify

imagify = Imagify('my_api_key')

param = dict(ultra=True, resize=dict(width=50))
image = '1.jpg'

imagify.optimize(image, param)
curl ""
  -H "Authorization: my_api_key" -H "Content-Type: multipart/form-data" -F "image=@1.jpg" -F "data={"ultra":true, "resize":{"width":50}}"

The above command returns JSON structured like this:

    "code": 200,
    "image": "",
    "new_size": 100,
    "original_size": 200,
    "percent": 50,
    "success": true

This endpoint allow you to upload and optimize an image.

HTTP Request


Query Parameters

Query parameters should be send as a form-data request

Parameter Type Description
image binary data Your image file required
data json A json with optimization parameters

Data Parameters

By filling the data parameter you will be able to control the optimization and to resize images.

Parameter Type Default Description
normal bool false Optimization with a losseless algorithm
aggressive bool true Optimization with Agressive algorithm
ultra bool false Optimization with Ultra algorithm
keep_exif bool false Will allow you to preserve meta data in images
resize bool false Array with resize paramater
resize[“width”] int false Will resize the image with the given width
resize[“height”] int false Will resize the image with the given height
resize[“percentage”] int false Will resize the image with the given percentage


Imagify API uses the following error codes:

Error Code Meaning
400 Bad Request – Your request was not understandable
422 Already compressed – Your image is already compressed
403 Forbidden – You don’t have the proper right to access the data
404 Not Found – The specified ressource could not be found
405 Method Not Allowed – You tried to access an endpoint with an invalid method
415 Unsupported media type – The file you’ve uploaded is not supported
500 Internal Server Error – We had a problem with our server. Try again later.
503 Service Unavailable – We’re temporarially offline for maintanance. Please try again later.