CSS Sprites Generator API Help

http://todo

The CSS Sprites Generator uses a very simple HTTP API. Simply send GET or POST requests (file uploads have to be POST of course) to this URL.

All requests except getToken require a token to be present - this is what identifies you to the system - like a session ID.

All responses are sent as UTF-8 JSON. They contain at least "message" property and an "error" property. Different requests may add other properties. If "error" is true then "message" will be the error message.

All requests may be made as many times as you like (but be reasonable!).

Step 1: Get your token

Request

api.php?getToken

Response

message
error
token
Your token for this session

Step 2a: Upload your files directly

You can upload files using a normal HTTP POST or simply send a URL for the server to download.

The file data should be encoded the same as if it were sent from an <input type="file" name="img">.

Files accepted are .png, .jpg, .jpeg, .gif and .zip (containing the aforementioned file types).

Request

api.php?upload&token=...

Response

message
error

Step 2b: Upload your files from a URL

Files accepted are .png, .jpg, .jpeg, .gif and .zip (containing the aforementioned file types).

NOT IMPLEMENTED

Request

api.php?uploadUrl&token=...&url=...

Response

message
error

Step 3: Create your Sprite

This may take a while - be patient!

Request

api.php?create&token=...

There are also several optional arguments you can pass in - more options may be coming soon:

padding (default = "3")
Padding to apply between images (pixels)
output_type (default = "png")
The output type you want (png, jpeg or gif)
jpeg_reduce_artefacts (default "0")
Pass in 1 to reduce jpeg artefacts (only used when output_type is jpeg)
jpeg_quality (default = "75")
The JPEG quality, from 0 to 100 (higher is better quality, bigger file) (only used when output_type is jpeg)

Response

message
error
url
The URL you can download your sprite from
css
The CSS you need to display your sprite correctly
info
A list containing information about each file in the sprite (see below)
oldSize
The sum of the filesizes of the uploaded files (bytes)
newSize
The filesize of the new file (bytes)
width
The width of the sprite (pixels)
height
The height of the sprite (pixels)