Imajs

Imajs is a simple image manipulation service based upon App Engine's Images API. It speaks JSON and Javascript, so you can even use it from client-side Javascript code.

Principles

Imajs will take, store, and manipulate images you give it. All images are immutable. That means that any operation that would change an image actually will create a new image. By default both the original image record and the new image record will be returned. All return values can be wrapped in user-specified Javascript callbacks, named by the callback request parameter. Each image must be under 1 MB in size.

Image records are represented by a standard JSON object. url and createdFrom can be null. It looks like this: {"key": "somekey", "name": "filename.extension", "mimetype": "image/format", width: 000, height: 000, "url": "http://somesite/filename.extension", "createdFrom": "anotherKey", "created": 0000000000}

Methods

create

create must be called via a POST request. You must include one of two parameters, url or image. url, if present, must be a full URL at which the image can be reached. image, if present, must be a binary image file. When both are included in the request, image is used. If Imajs is unable to create an image, you will get an appropriate HTTP error status code. Success will be indicated by a 201 HTTP status code and its body will be a JSON object representing the image. Important properties include key and created. As mentioned earlier, a callback parameter can be passed. If it is, the Content-Type will be application/javascript. Otherwise the Content-Type will be application/json.

Example

curl -d "url=http%3A//www.bubblefoundry.com/files/bubblefoundrylogo.png" http://appimajs.appspot.com/create
curl -d "image=@/tmp/somefile.png" http://appimajs.appspot.com/create

resize

resize must be called via a POST request. You must reference the original image via a key, url, or image parameter. The key parameter references an image created via create. url and image work exactly the same as the create parameters. Other parameters you can pass are width, height, and mimetype. Width and height default to those of the original image. The image will be resized while keeping its proportions so that its resulting width and height are both less than or equal to the width and height specified. mimetype is the format of the resized image and may be either image/png (the default) or image/jpeg. By default a JSON object will be returned with image and parent JSON image objects. Only the image JSON object will be returned if the optional parent request parameter is false.

Example

curl -d "key=aghhcHBpbWFqc3ILCxIFSW1hZ2UYAQw&width=200&height=200" http://appimajs.appspot.com/resize

view

view must be called with a GET request with one parameter, key. It will return the image with the appropriate Content-Type header.

Example

http://appimajs.appspot.com/view?key=aghhcHBpbWFqc3ILCxIFSW1hZ2UYAQw

Credits

By Peter Robinett (@pr1001) of Bubble Foundry

NOTE: As mentioned above, I store every single image version. This is only a proof-of-concept so please don't abuse my App Engine quota or rely on it.