Processing an image via Rest API

Processing an image

It’s time to start with image processing, but if you still don’t know how to create a project and authenticate it, please refer to the Getting started guide.


The image processing workflow with iLoveAPI is very simple for all the tools and consists of 4 basic instructions: Start task, Upload files, Process files and Download files. Once the API has executed these steps, you will have your image files processed using your desired tool and downloaded to anywhere you like.


The iLoveAPI offers many options and custom functions for every tool, but for now we’ll just focus on how to perform a simple task with very few code lines. Once you have finished reading this guide, we recommend that you take a look at the common attributes you can set on any task in the Common functions guide.

Start task

To start a task, you need to create it directly with an API instance:

Start task

Please note that the first two lines were set in order to authenticate our project with the API servers. That way you only need to authenticate once per project instead of for every task you create!

Upload files

The next step is to assign all the files that you (or your users) want to upload by adding these files to the task like in this code example:

Upload files

This example adds the path to the task and the name of three files to upload. You will see in further guides that you can upload files from URL using dedicated API functions.

Process files

Now it’s time to execute your process:

Process files

Download

Finally download task results, and you'll have compressed three image files only with a few lines of code!

Download

Full code

This is what the full code looks like

Full code example

Open task limitation

For security reasons and to avoid an overflow of requests to the API, please note that there's a limitation to the maximum number of tasks that can be opened at a time: 10% of your monthly subscription’s file limit. A task is opened from the moment you upload a file until you process it (*see password- protected files exception). Remember this limitation if you have to create a large number of tasks.

For password-protected files, a task will not be processed (therefore not closed) until a password is set for these files.

Test a library

You can download this example here in any of the compatible API languages.


Now you’re ready to visit our Common functions guide for a more advanced use of our image processing tools.