RESIZEGIF API Endpoint

Version 2.197 (Release Notes ↗)

Description

Scales a GIF file to the desired dimensions. Use resize for other media format. This endpoint is available starting from the Prod Plan and up.

HTTP Methods

GET, POST

HTTP Parameters

Required

Fields Type Description
img URL Input GIF URL. If you want to upload your GIF directly from your app, call store before invoking this endpoint.
width Integer Desired new Width. If omitted, the height value will be used for proportional scaling.
height Integer Desired new Height. If omitted, the width value will be used for proportional scaling.
key String Your PixLab API Key ↗. Alternatively, embed your key in the WWW-Authenticate: HTTP header to omit this parameter.

Optional

Fields Type Description
blob Boolean Returns the raw GIF binary data when set to true. Default behavior returns a JSON response with the output URL.

POST Request Body

Use when making POST requests instead of GET.

Allowed Content-Types:

multipart/form-data
application/json

Use multipart/form-data for direct file uploads (see examples). For JSON, ensure the media file is already hosted elsewhere. Call store to upload files before processing.

HTTP Response

Fields Type Description
status Integer Status code 200 indicates success, any other code indicates failure.
link URL Link to the gif output which is usually stored on the pixlab.xyz storage server unless you set your own S3 keys (refer to your dashboard ↗ on how to do that).
id String Unique media ID.
error String Error message if status != 200.

The API returns application/json if the optional blob parameter is not set.

This endpoint returns a JSON Object after each call only if the optional blob parameter is omitted. When blob is set, the GIF binary data is returned directly. The response JSON contains the following fields:

Code Samples


import requests


def resize_gif(image_url: str, width: int, height: int, api_key: str) -> str:
    """Resize a GIF using the PixLab API and return the processed image URL."""
    params = {
        'img': image_url,
        'key': api_key,
        'width': width,
        'height': height,
    }
    
    try:
        response = requests.get(
            'https://api.pixlab.io/resizegif',
            params=params,
            timeout=10
        )
        response.raise_for_status()
        data = response.json()
        
        if data['status'] != 200:
            raise ValueError(data.get('error', 'Unknown error occurred'))
            
        return data['link']
        
    except requests.exceptions.RequestException as e:
        raise ConnectionError(f"API request failed: {e}") from e


if __name__ == "__main__":
    try:
        gif_url = resize_gif(
            image_url='http://cloud.addictivetips.com/wp-content/uploads/2009/testing.gif',
            width=256,
            height=256,
            api_key='PIXLAB_API_KEY'
        )
        print(f"GIF location: {gif_url}")
    except Exception as e:
        print(f"Error: {e}")
← Return to API Endpoint Listing