Multiprocessing - Overview

Multiprocessing / Overview

Optidash offers a multiprocessing mode, enabling the generation of multiple image sets through a single API call. This feature facilitates the creation of comprehensive responsive image sets from a single upload or fetch operation. By utilizing multiprocessing, users can significantly reduce bandwidth consumption and network overhead, thereby streamlining the processing workflow.

To activate multiprocessing, encase multiple JSON parameters within an array of objects. This array should then be assigned as the value for the multi key. This method ensures efficient handling of various processing parameters without the necessity of multiple image uploads.

{
    "multi": [{
        "resize": {
            "width": 320,
            "height": 240,
            "mode": "fit"
        },
        "output": {
            "format": "webp"
        }
    },
    {
        "resize": {
            "width": 320,
            "height": 240,
            "mode": "auto"
        },
        "output": {
            "format": "avif"
        }
    }]
}

The aforementioned API call yields the following response:

{
    "success": true,
    "code": 200,
    "id": "c66e040d-2cb4-4330-8b01-0a7ce88039ed",
    "input": {
        "name": "example.jpg",
        "format": "jpeg",
        "width": 1024,
        "height": 768
        ...
    },
    "output": [
        {
            "url": "https://s3.optidash.ai/fddcff8b-02cf-491c-af39-664cdf15b788/example.webp",
            "name": "01.webp",
            "format": "webp",
            "width": 320,
            "height": 240
            ...
        },
        {
            "url": "https://s3.optidash.ai/07b02c6d-a55f-4e56-9459-cb12fb41acae/example.avif",
            "name": "01.avif",
            "format": "heif",
            "width": 640,
            "height": 480
            ...
        }
    ]
}

It is important to be aware that enabling multiprocessing modifies the structure of the response body. Specifically, the output transforms into an array of objects. The sequence of these objects mirrors the arrangement of objects in the initial request.

In the context of the multi array, each object functions as an independent entity, akin to the standard single-image processing approach. This independence allows for the customization of each object with any parameter available in Optidash's comprehensive suite. A notable application of this feature is in PDF processing, where it is possible to extract and process multiple pages from a single document. Subsequently, each processed page can be stored individually in a distinct Object Storage of your choice. For example:

{
    "multi": [{
        "frame": 1,
        "store": {
            "id": "your-first-id",
            "bucket": "optidash-example",
            "path": "/pdf/pages/01.png"
        },
        "resize": {
            "width": 800
        },
        "output": {
            "format": "png"
        }
    },
    {
        "frame": 2,
        "store": {
            "id": "your-second-id",
            "bucket": "optidash-example",
            "path": "/pdf/pages/02.png"
        },
        "resize": {
            "width": 800
        },
        "output": {
            "format": "png"
        }
    }]
}

By default, the Optidash API allows for up to eight distinct requests to be included within the multi array. However, for Enterprise customers seeking enhanced capabilities, we offer the option to increase this limit. If you require a higher capacity for your multiprocessing needs, please contact our team, and we will customize the limits on your account accordingly.