Thumbnails API in Wasabi AiR
    • 20 May 2024
    • 1 Minute to read
    • PDF

    Thumbnails API in Wasabi AiR

    • PDF

    Article summary

    Serving Thumbnails

    Wasabi AiR serves thumbnails and frames through the /api/files endpoint. Refer to the Files API.

    GET /api/files/{item_id}/{path}

    The path value comes from the thumbnail structure described below.

    Thumbnail Structure

    Wasabi AiR attempts to generate a thumbnail for every item, the results of which are stored in the thumbnail structure in the Item Object.

    {
        "thumbnail": {
            "type": "{type}",
            "path": "{path}",
            "width": {width},
            "height": {height},
            "frames": {
                "count": {frame-count}
            }
        }
    }
    • {type} - (string) The type of the thumbnail (see the Thumbnail Types below).
    • {path} - (string) The path to the thumbnail that can be used to download or display the image.
    • {width} - (int) The width of the thumbnail.
    • {height} - (int) The height of the thumbnail.
    • {frame-count} - (int) The number of frames represented in a sprite thumbnail.

    Thumbnail Types

    Wasabi AiR may produce one of many types of thumbnails. The dimensions of the image are thumbnail.width by thumbnail.height.

    Images

    Most thumbnails are normal images, and they have the image type.

    Sprites

    Thumbnails with the sprite type indicate that the image is wide and made up of many frames. The number of frames are present in the frames.count field.

    The true width of the image is width x frames.count. The viewport should be width by height.

    Rotating a Thumbnail

    You can rotate an image item thumbnail. This is valid only for an item that has a gm_item_type of image.


    PATCH /api/data/v3/items/{item_id}/thumbnail

    PATCH /api/data/v3/items/{item_id}/thumbnail
    
    {
       "rotation": ENUM["clockwise" | "counterclockwise" | "flip"]
    }
    • clockwise - Rotates the thumbnail clockwise 90 degrees.
    • counterclockwise - Rotates the thumbnail counterclockwise 90 degrees.
    • flip - Rotates the image 180 degrees.