RESTful Image Processing

Description

The dotCMS 1.9 series introduced the online image editor - a great tool for content editors to manipulate uploaded images.  But almost important is that underlying the image editor is a RESTful interface for manipulating images stored in dotCMS.  All functions in the image editor can be called via a cacheable URL, which is very helpful and important to web developers looking to automatically resize or edit images for use in your web sites and widgets.  

The way it works is the image passes through a series of filters, each of which can take 0 or more parameters.  The resultant modifed image is then passed through the next filter for processing.  In the example below, we take the same image and pass it through a number of filters, each of which process the image.

Important to note : the resultant image is generated once and then cached on the dotCMS server for performance.

Below are some examples of filters that can be applied.  The first example is the RAW source image, which is a JPEG.  The second shows the image resized to 300px wide, though the resized image has been transformed into a PNG.  The third image shows the resized image, though this time the image is being exported as a JPEG, with quality of 75%.  The fourth image show the same image, resized and saturation decreased by 75%, exported as a JPEG.

Click here for the entire documentation for this API.

Original Image by Version (Inode) (jpeg):

http://demo.dotcms.com/contentAsset/image/3bcfdf09-97f1-494f-8cef-925e36a86c0b/fileAsset/byInode/1

Image Resized (png):


http://demo.dotcms.com/contentAsset/image/3bcfdf09-97f1-494f-8cef-925e36a86c0b/fileAsset/byInode/1/filter/Resize/resize_w/300

Image Resized, JPEG Quality 75:


http://demo.dotcms.com/contentAsset/image/3bcfdf09-97f1-494f-8cef-925e36a86c0b/fileAsset/byInode/1/filter/Resize,Jpeg/resize_w/300/jpeg_q/75

Image Resized, Saturation -.75, JPEG Quality 75:


http://demo.dotcms.com/contentAsset/image/3bcfdf09-97f1-494f-8cef-925e36a86c0b/fileAsset/byInode/1/filter/Resize,Hsb,Jpeg/resize_w/300/hsb_h/0.00/hsb_s/-0.75/hsb_b/0.00/jpeg_q/75

Code

See Above