API Documentation

Basic call

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

  • GET Parameter "img"
  • POST Parameter "img"
  • FILES binary sent "files"

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

API output

reSmush.it is able to answer in :

  • JSon (default)
  • XML output is disabled since Jan, 1st of 2019.

The output array contains several informations, such as :

  • the source URL (if using GET or POST method) (parameter dest)
  • the url of the optimized picture (parameter dest)
  • the original file size (parameter src_size)
  • the optimized file size (parameter dest_size)
  • the percentage of gain (parameter percent)
  • the date when the file will be deleted from the server (parameter expires)
  • the error code (parameter error)
  • the error description (parameter error_long)

An example of the JSON output can be found below : 

{
"src": "http://www.resmush.it/assets/images/compare_1_original.jpg",
"dest": "http://rou4.static.resmush.it/4dda5bd3e509fab7afbc45afa8c9a56c/compare_1_original.jpg",
"src_size": 383771,
"dest_size": 4494,
"percent": 99,
"output": "json",
"expires": "Sun, 05 May 2019 18:03:18 +0200",
"generator": "reSmush.it rev.2.0.3.20190108"
}

Compression

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 :

  • qlty with a value between 0 and 100. Default value is 92

For having a good image quality, please remain above 90

Example of use : http://api.resmush.it/?img=http://www.resmush.it/assets/images/jpg_example_original.jpg&qlty=95

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 :

  • exif with the value true Default value is false

API Errors

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

  • 301 : old endpoint used. Consider using api.resmush.it instead.
  • 400 : no url of image provided
  • 401 : impossible to fetch the image from URL (usually a local URL)
  • 402 : impossible to fetch the image from $_FILES (usually a local URL)
  • 403 : forbidden file format provided. Works strictly with jpg, png, gif, tif and bmp files.
  • 404 : unknown method or resource requested.
  • 501 : internal error, cannot create a local copy
  • 502 : image provided too large (must be below 5MB)
  • 503 : internal error, could not reach remote reSmush.it servers for image optimization
  • 504 : internal error, could not fetch picture from remote reSmush.it servers

Compatibility

reSmush.it is 100% compatible with old non-working Yahoo Smush.it webservice.

You'll just have to replace the old API call http://www.smushit.com/ysmush.it/ws.php?img= by the reSmush.it webservice url, which works exactly the same way http://api.resmush.it/ws.php?img= and everything will be fine!

reSmush.it has been tested successfully with Drupal's ImageAPI Optimize (dev version) module and with the reSmush.it official Wordpress plugin reSmush.it Image Optimizer.