1. Go to this page and download the library: Download aiger-team/image-tools library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aiger-team / image-tools example snippets
use AigerTeam\ImageTools\ImageFactory;
(new ImageFactory())
->openFile('image.jpg')
->resize(600, 500)
->toFile('image-resized.jpg');
use AigerTeam\ImageTools\ImageFactory;
// List of thumb to create. The values are width, height and "put watermark?".
$thumbsSizes = [
[150, 80, false],
[300, 200, true],
[500, 400, true]
];
// Open uploaded image and watermark image
$factory = new ImageFactory();
$image = $factory->openFile($_FILES['image']['tmp_name']);
$watermark = $factory->openFile('watermark.png');
// Make thumbs
$thumbsFiles = array_map(function($size) use ($image, $watermark)
{
$thumb = $image->resize($size[0], $size[1], false, $image::SIZING_COVER); // Original $image is not modified so thumbs may be created in any order
if ($size[2]) {
$thumb = $thumb->stamp($watermark, 0.2); // Watermark size is relative, not pixel
}
return $thumb->toUncertainFile('uploads/thumbs'); // File name and format is set automatically
}, $thumbSizes);
use AigerTeam\ImageTools\ImageFactory;
$factory = new ImageFactory();
$image = $factory->blank(100, 150);
use AigerTeam\ImageTools\Image;
$resource = imagecreatetruecolor(100, 150);
$image = new Image($resource);
// WRONG! Don't do this or you will be fired.
$image->resize(200, 150);
$image->toFile('image.jpg');