- Get started
- Overview
- Getting started
- Processing an image
- Common functions
- Error handling
- Tool guides
-
Compress images
-
Resize images
-
Crop images
-
Convert images
-
Rotate images
-
Watermark images
-
Repair images
Resources
Convert Images Guide
Create your own Image Converter to transform PNG, GIF, TIF, PSD, SVG, WEBP and RAW to JPG in seconds.
New to the API? Start with Processing an image: every tool guide builds on its task flow.
Convert to JPG
By default all images will be converted to JPG, simply use this code sample to convert your images to JPG:
Start taskPHP
// 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();PHP library ilovepdf/iloveimg-php
composer require ilovepdf/iloveimg-phpConvert JPG to PNG
In order to convert to PNG you just need to set the property to to png.
Start taskPHP
// Create a new task
$myTaskConvert = $iloveimg->newTask('convert');
// Add files to task for upload
$file1 = $myTaskConvert->addFile('path/to/file1_name.jpg');
$myTaskConvert->setTo('png');
// Execute the task
$myTaskConvert->execute();
// Download the package files
$myTaskConvert->download();PHP library ilovepdf/iloveimg-php
composer require ilovepdf/iloveimg-phpConvert JPG to static GIF
In order to convert to a static GIF you just need to set the property to to gif.
Start taskPHP
// 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();PHP library ilovepdf/iloveimg-php
composer require ilovepdf/iloveimg-phpConvert JPG to animated GIF
In order to join all the images of the task into a single animated GIF you just need to set the property to to gif_animation.
Start taskPHP
// Create a new task
$myTaskConvert = $iloveimg->newTask('convert');
// Add files to task for upload
$file1 = $myTaskConvert->addFile('path/to/file1_name.jpg');
$file2 = $myTaskConvert->addFile('path/to/file2_name.jpg');
$myTaskConvert->setTo('gif_animation');
$myTaskConvert->setGifTime(50);
$myTaskConvert->setGifLoop(true);
// Execute the task
$myTaskConvert->execute();
// Download the package files
$myTaskConvert->download();PHP library ilovepdf/iloveimg-php
composer require ilovepdf/iloveimg-phpWith this option you can also configure the time each image is shown (in hundredths of a second, default 50) and whether the animation loops (default true) with the properties gif_time and gif_loop.