PHP code example of dmcblue / php-image-resize

1. Go to this page and download the library: Download dmcblue/php-image-resize 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/ */

    

dmcblue / php-image-resize example snippets


// Load composer libs
\Dmcblue\ImageResize\ImageResizer();
$configArray = 
	[
		'originalPath' => '/path/to/original/images',
		'sizeConfigs' => [[
			'outputPath' => '/path/to/resized/images/thumbnails',
			'postfix' => '_thumbnail',
			'type' => \Dmcblue\ImageResize\Type::COVER,
			'width' => 50,
			'height' => 50,
		],[
			'outputPath' => '/path/to/resized/images/large',
			'postfix' => '_lrg',
			'type' => \Dmcblue\ImageResize\Type::CONTAIN,
			'width' => 2000,
			'height' => 2000,
		]]
	];
$config = new \Dmcblue\ImageResize\Config($configArray);
$imageResizer->resizeAll($config);
// Or resize a single image
$imageResizer->resize('/path/to/original/image.jpg', $config);
// Creates
//    /path/to/resized/images/thumbnails/image_thumbnail.jpg
//    /path/to/resized/images/large/image_lrg.jpg

"./vendor/bin/phpunit" --bootstrap "vendor/autoload.php" tests