imager200 API offers the possiblity to send requests in two modes: Sync (Synchronous) and Async (Asynchronous). In the Sync mode, the image is processed immediately and sent back with the response. The response is suspended until the processing finishes. This can be useful if the result is needed immediately. The waiting time will vary depending on the operation and the size of the image.
Using the Async mode, a response is returned immediately with an empty body, then the image is processed, and:
- in case no post operation id is specified in the
X-PostOp-Id
header, it will store the image in our temporary storage and sends back the address in theLocation
header. The link will expire within 24h, so you need to download the image within this timeframe. - otherwise, it will store and name the image file according to the post operation configuration specified by the id in the
X-PostOp-Id
header.
Each endpoint supports both sync and async modes. By default all the endpoints are async. In case the sync mode is desired, it is enough to add /sync
to the path (e.g /crop/sync
)
When to use Async
Async mode can be useful if you are doing bulk processing, or if you would like your image to be stored automatically after processing in a third party storage service (Dropbox, Google Drive, AWS S3,….).
Example
Sync mode
curl -v -o crop_example.jpeg -H "X-Imager-Key: YOUR_API_KEY" --data-binary @jpeg_image.jpg 'https://api.imager200.io/crop/sync?x0=100&y0=150&x1=350&y1=400'
Async mode
curl -v -H "X-Imager-Key: YOUR_API_KEY" --data-binary @jpeg_image.jpg 'https://api.imager200.io/crop?x0=100&y0=150&x1=350&y1=400'
Location: http://storage.imager200.io/d4evEvobR2CiJqbNPwdcCDzfaarsxW/temp_1562596297151.jpeg
Still confused ? Checkout our explanatory screencast: