PHP code example of intervention / image
1. Go to this page and download the library: Download intervention/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/ */
intervention / image example snippets
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Gd\Driver as GdDriver;
use Intervention\Image\Alignment;
use Intervention\Image\Color;
use Intervention\Image\Format;
// create image manager instance using the preferred driver
$manager = ImageManager::usingDriver(GdDriver::class);
// read image data from path
$image = $manager->decodePath('images/example.webp');
// scale image by height
$image->scale(height: 300);
// insert a watermark
$image->insert('images/watermark.png', alignment: Alignment::BOTTOM_RIGHT);
// encode edited image
$encoded = $image->encodeUsingFormat(Format::JPEG, quality: 65);
// save encoded image
$encoded->save('images/example.jpg');