SHADE API Endpoint

Version 2.197 (Release Notes ↗)

Description

Creates a 3D effect. Shines a distant light on an image to create a three-dimensional effect. You control the positioning of the light with azimuth and elevation; azimuth is measured in degrees off the x axis and elevation is measured in pixels above the Z axis.

HTTP Methods

GET, POST

HTTP Parameters

Required

Fields Type Description
img URL Input image URL. If you want to upload your image directly from your app, submit a multipart/form-data POST request.
gray Boolean A value other than zero shades the intensity of each pixel.
azimuth Float Defines the light source direction.
elevation Float Defines the light source direction.
key String Your PixLab API Key ↗. You can also embed your key in the WWW-Authenticate: HTTP header and omit this parameter.

Optional

Fields Type Description
blob Boolean By default, returns a JSON Object with the output image link. Set to true to receive the image binary contents instead.

POST Request Body

Use this if you plan to submit a POST request instead of GET.

Allowed Content-Types:

  • multipart/form-data
  • application/json

Use multipart/form-data for direct image uploads (check the REST API code samples or The PixLab Github Repository↗ for examples). For JSON, ensure your image is already hosted. Call store to upload an image before invoking this endpoint.

HTTP Response

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

This endpoint returns a JSON Object after each call unless the blob parameter is specified, in which case the image binary contents are returned directly. The response JSON contains the following fields:

Fields Type Description
status Integer Status code 200 indicates success, any other code indicates failure.
link URL Link to the processed image stored on our servers unless custom S3 keys are configured (see your dashboard ↗ for configuration).
id String Unique identifier for the processed image.
error String Error message when status != 200.

Code Samples


import requests

def process_image():
    try:
        response = requests.get(
            'https://api.pixlab.io/shade',
            params={
                'img': 'http://cf.broadsheet.ie/wp-content/uploads/2015/03/jeremy-clarkson_3090507b.jpg',
                'gray': 1,
                'elevation': 4,
                'key': 'PIXLAB_API_KEY'
            },
            timeout=10
        )
        response.raise_for_status()
        data = response.json()
        
        if data.get('status') == 200:
            print(f"Link to the pic: {data['link']}")
        else:
            print(data.get('error', 'Unknown error occurred'))
            
    except requests.exceptions.RequestException as e:
        print(f"Request failed: {e}")
    except ValueError:
        print("Invalid JSON response")
    except Exception as e:
        print(f"An unexpected error occurred: {e}")

if __name__ == "__main__":
    process_image()
← Return to API Endpoint Listing