Resize Images Guide

Develop your own solution to automatically resize images in bulk by integrating with the iLoveIMG REST API.

New to the API? Start with Processing an image: every tool guide builds on its task flow.

Resize by pixels

If property resize_mode is set to pixels, an image can be resized by specific pixel size.

Start taskPHP
// Create a new task
$myTaskResize = $iloveimg->newTask('resize');

// Add files to task for upload
$file1 = $myTaskResize->addFile('path/to/file1_name.jpg');
$file2 = $myTaskResize->addFile('path/to/file2_name.png');

// Set the pixels mode and size
$myTaskResize->setResizeMode('pixels');
$myTaskResize->setPixelsWidth(500);
$myTaskResize->setPixelsHeight(500);

// Execute the task
$myTaskResize->execute();

// Download the package files
$myTaskResize->download();
PHP library ilovepdf/iloveimg-phpcomposer require ilovepdf/iloveimg-php

This mode can be configured with properties pixels_width and pixels_height in order to set the width and height of the resized image.

Resize by percentage

If property resize_mode is set to percentage, an image can be resized by specific percentage amount.

Start taskPHP
// Create a new task
$myTaskResize = $iloveimg->newTask('resize');

// Add files to task for upload
$file1 = $myTaskResize->addFile('path/to/file1_name.jpg');
$file2 = $myTaskResize->addFile('path/to/file2_name.png');

// Set the percent mode and value
$myTaskResize->setResizeMode('percentage');
$myTaskResize->setPercentage(50);

// Execute the task
$myTaskResize->execute();

// Download the package files
$myTaskResize->download();
PHP library ilovepdf/iloveimg-phpcomposer require ilovepdf/iloveimg-php