- Image REST API Guides
- Welcome
- First steps
- Getting started
- Processing an image
- Common functions
- Topics
- Error handling
- Tool guides
- Resize Images Guide
- Crop Images Guide
- Compress Images Guide
- Convert Images Guide
- Rotate Images Guide
- Watermark Image Guide
- Repair Image Guide
Convert Images Guide
Create your own Image Converter to transform PNG, GIF, TIF, PSD, SVG, WEBP and RAW to JPG in seconds.
Remember that in order to use our Tool Guides, you need to have previous knowledge about the basics to
processing a PDF with our REST API. We strongly recommend that you read the Processing a PDF guide
before starting this one.
Convert to JPG
By default all images will be converted to JPG, simply use this code sample to convert your images to jpg:
Start task
x
// Create a new task
$myTaskConvert = $iloveimg->newTask('convert');
// Add files to task for upload
$file1 = $myTaskConvert->addFile('path/to/file1_name.tiff');
$file2 = $myTaskConvert->addFile('path/to/file2_name.png');
// Execute the task
$myTaskConvert->execute();
// Download the package files
$myTaskConvert->download();
Convert JPG to PNG
In order to convert to png you just need to set the property to to png.
Start task
xxxxxxxxxx
// Create a new task
$myTaskConvert = $iloveimg->newTask('convert');
// Add files to task for upload
$file1 = $myTaskConvert->addFile('path/to/file1_name.tiff');
$file2 = $myTaskConvert->addFile('path/to/file2_name.png');
// Execute the task
$myTaskConvert->execute();
// Download the package files
$myTaskConvert->download();
Convert JPG to static GIF
In order to convert to png you just need to set the property to to gif.
Start task
xxxxxxxxxx
// Create a new task
$myTaskConvert = $iloveimg->newTask('convert');
// Add files to task for upload
$file1 = $myTaskConvert->addFile('path/to/file1_name.jpg');
$myTaskConvert->setTo('gif');
// Execute the task
$myTaskConvert->execute();
// Download the package files
$myTaskConvert->download();
Convert JPG to animated GIF
In order to convert to png you just need to set the property to to gif_animation.
Start task
xxxxxxxxxx
// Create a new task
$myTaskConvert = $iloveimg->newTask('convert');
// Add files to task for upload
$file1 = $myTaskConvert->addFile('path/to/file1_name.jpg');
$myTaskConvert->setTo('gif_animation');
$myTaskConvert->setGifTime(50);
$myTaskConvert->setGifLoop(true);
// Execute the task
$myTaskCompress->execute();
// Download the package files
$myTaskCompress->download();
Also, with this option can be configured the animation time and its loop with the properties gif_time and gif_loop