PHP code example of horde / image

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

    

horde / image example snippets


use Horde\Image\Driver\ImagickDriver;
use Horde\Image\Color\Color;
use Horde\Image\Format\ImageFormat;
use Horde\Image\Geometry\Size;

$driver = new ImagickDriver();
$image = $driver->create(new Size(800.0, 600.0), Color::named('white'));

$resized = $image->resize(new Size(400.0, 300.0));
$data = $driver->encode($resized, ImageFormat::JPEG);
file_put_contents('output.jpg', $data);