PHP code example of intervention / image-driver-vips
1. Go to this page and download the library: Download intervention/image-driver-vips 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-driver-vips example snippets
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Vips\Driver as VipsDriver;
use Intervention\Image\Alignment;
use Intervention\Image\Format;
// create image manager instance using the desired driver
$manager = ImageManager::usingDriver(VipsDriver::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: Format::JPEG, quality: 65);
// save encoded image
$encoded->save('images/example.jpg');