PHP code example of byjg / imageutil

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

    

byjg / imageutil example snippets



use ByJG\ImageUtil\ImageUtil;

// From a file
$img = ImageUtil::fromFile('path_to_image.png');

// From a URL
$img2 = ImageUtil::fromFile('https://somesite/someimage.jpg');

// From an existing resource image
$resourceImg = imagecreatetruecolor(200, 300);
$img3 = ImageUtil::fromResource($resourceImg);

// Or an empty image
$img4 = ImageUtil::empty(200, 300, new Color(255, 255, 255));


use ByJG\ImageUtil\ImageUtil;

$img = ImageUtil::fromFile('path_to_image.svg');
$img->save('path_to_image.png');


$img->save('filename.gif');
$img->restore();
$img->destroy();


$width = $img->getWidth();
$height = $img->getHeight();
$resource = $img->getResource();