: Image optimization API

API, How to use

Basic call

For a standard call, with a JSON response, you just have to call this url and provide the image attribute like one of these options below :

The webservice will return an array of informations about the compressed image (see below)

API output is able to answer in :

The output array contains several informations, such as :


Since July 2015 (v.1.4.2), you can now specify your optimization level for JPG compression. To do so, just add the following parameter in GET method :

For having a good image quality, please remain above 90

Example of use :

EXIF data

Since Feb 2017 (v.1.4.21), EXIF data are remove by default, reducing file size. However, these data can be keeped while compression by specifying the following parameter in GET method :

API Errors

Here is the list of the differents errors of the webservice :

Compatibility is 100% compatible with old non-working Yahoo webservice.

You'll just have to replace the old API call by the webservice url, which works exactly the same way and everything will be fine! has been tested successfully with Drupal's ImageAPI Optimize (dev version) module and with the official Wordpress plugin Image Optimizer.

Examples of implementation (PHP)

#1 Simple PHP request (using GET and with a JSON response)

define('WEBSERVICE', '');
$s = 'http://www.mywebsite/image.jpg';
$o = json_decode(file_get_contents(WEBSERVICE . $s));

echo $o->dest; //URL of the optimized picture

#2 PHP Request (sending file directly to the API). Recommended method !


    $file = '/path/to/myfile.jpg';
    $mime = mime_content_type($file);
    $info = pathinfo($file);
    $name = $info['basename'];
    $output = new CURLFile($file, $mime, $name);
    $data = array(
        "files" => $output,

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, '');
    curl_setopt($ch, CURLOPT_POST,1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    $result = curl_exec($ch);
    if (curl_errno($ch)) {
       $result = curl_error($ch);
    curl_close ($ch);