PHP code example of glaivepro / image

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

    

glaivepro / image example snippets


$uri = GPImage::url('img/some-image.jpg', 120, 150);
// $uri is 'img/some-image-image(120x150).jpg'

$url = GPImage::asset('img/some-image.jpg', 120, 150);
// $url is 'https://example.com/img/some-image-image(120x150).jpg'

use GlaivePro\Image\Uri;

$uri = new Uri('pic.jpg');
$uri->size(20, 400);

(string) $uri; // 'pic-image(20x400).jpg'

GPImage::asset('pic.jpg')->pixelate(12)->blur(10)->resize(100, 200);
// https://example.com/pic-image(pixelate(12)-blur(10)-resize(100,200)).jpg

// Called via 'somepic-image(simplefilter).jpg'
GPImage::filter('simplefilter', fn ($image) => $image->anyInterventionMethod());

// Called via 'somepic-image(complexfilter(10,20))'
GPImage::filter('complexfilter', function($image, $arg1, $arg2) {
	$tempArg = $arg1 * 2;
	$image->someInterventionMethod($tempArg, $arg1);
	$image->someOtherInterventionMethod();
});