PHP code example of innobotics / imageresize

1. Go to this page and download the library: Download innobotics/imageresize 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/ */

    

innobotics / imageresize example snippets




$image = new \Innobotics\ImageResize();

$image->setType('large', 640, 480);
$image->setType('medium', 320, 240);
$image->setType('thumbnail', 160, 120);
$image->setType('content', 500, null); // You can add 'null' as height. It won't be cropped.

$image->setSource('/home/notesz/teszt/bianka_160117.jpg');

$image->setTarget('/home/notesz/teszt/resized');

$image->setFileName('bianka.jpg'); //optional

$image->setCompression(100); //optional

$image->setCompressionType(8); //optional

$image->setPrefix('image'); //optional

$image->setProgressive(false); //optional

$image->setRetina(true); //optional

$image->setSaveOriginal(false); //optional

if ($image->resize() === true) {
    print 'It\s okay! :)';
} else {
    print 'Something happened!';
}

print_r($image->getResult());

Array
(
    [status] => success
    [message] => Array
        (
            [files] => Array
                (
                    [large] => image_bianka_large.jpg
                    [medium] => image_bianka_medium.jpg
                    [thumbnail] => image_bianka_thumbnail.jpg
                    [original] => image_bianka.jpg
                )

        )

)

Array
(
    [status] => error
    [message] => unable to open image `/home/notesz/teszt/IMG_790s7.jpg': No such file or directory @ error/blob.c/OpenBlob/2638
)