Common functions
Functions and attributes for Upload
You can upload files from the following storage types:
- Local
- Web
Upload from local
For local files,you must assign them to the created Task tool and it is necessary always set a local path filename in order to upload it.
Upload from web
Uploading from the Web works in the same way as uploading from local but using a public URL.
File attributes
You can set rotation attribute:
Rotate a file
It's possible to rotate the orientation of any uploaded file by using the rotate property with one of four direction parameters (Up = 0, Right = 90, Down = 180, Left = 270);
Delete files
You may need to delete previously uploaded files from a task. In this case, you can use the following delete function:
Advanced processing
We have now seen how to process an image files in a very basic way. Now we will go through more processing instructions which have more advanced and common options to consider. You will see that each tool has its own advanced processing customization options, but here we will focus on those common to all the tools.
Example code:
Ignore file errors
Some of the uploaded files may be damaged and therefore cannot be processed. ignore_errors allows you to ignore those damaged files and force the task to process only the good ones.
Tasks have ignore_errors set to true by default so you won’t need this function unless you want to force an error message for any damaged file.
Try to repair a damaged image
One of the newest iLoveIMG features is the possibility to repair damaged image files. By default the API tries to repair any damaged file but this feature can be disabled with:
Set output filename
As a rule, the output filename of files will be the same as the input filename in most cases. However, it depends on the tool used. You can also customize the output filename with output_filename.
This function works with simple strings made up of the following predefined vars:
- {filename} = original filename
- {n} = file number
- {date} = current date
- {tool} = current processing action
So the final output name could be:
Set a package filename
iLoveIMG API will always pack multiple output files in a single compressed file. You can set this package filename with packaged_filename and the following predefined vars:
- {filename} = original filename
- {date} = current date
- {tool} = current processing action
So the final output name could be:
Functions for download
Download functions are exactly the same as the basic upload functions and allow you to download your output files.
Now that you know all the common advanced features for Upload, Process and Download instructions, you are ready to dive into the functioning of the iLoveIMG API Tools.