PHP code example of nigabrein / acimage
1. Go to this page and download the library: Download nigabrein/acimage 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/ */
nigabrein / acimage example snippets
$targetPath = 'images/folder1/folder2/file.png';
$img = AcImage::createImage(Yii::getAlias('@web').$targetPath);
$sizes = [800, 400, 150];
$thumbnails_folder = 3;
$parts = explode('/', $targetPath);
$directory = implode('/', array_slice($parts, 0, -1));
$filename = end($parts);
foreach ($sizes as $size) {
$img->thumbnail($size, $size, 3);
$img->save(Yii::getAlias('@web') . $directory ."/thumbnails/size_". $thumbnails_folder ."/" . $filename);
$thumbnails_folder--;
}