1. Go to this page and download the library: Download mehr-it/levi-images 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/ */
mehr-it / levi-images example snippets
LeviImages::raster()
// open a file
$im = LeviImages::raster()->open('path/to/file.png');
// load a string
$im = LeviImages::raster()->load(/* image data as string */);
// read from a resource
$im = LeviImages::raster()->load(fopen('path/to/file.png', 'r'));
// levi-images.php
return [
'raster' => [
/*
* Configures the raster image driver to use. Available options are "vips", "imagick", "gmagick" and "gd". If
* "auto" is set, the first available driver is chosen.
*/
'driver' => 'vips',
],
];
$size = new Box(100, 100);
$bgColor = (new RGB())->color("ff0000", 1); // red
$im = LeviImages::raster()->create($size, $bgColor);
// open a file
$im = LeviImages::raster()->open('path/to/file.svg');
// load a string
$im = LeviImages::raster()->load(/* image data as string */);
// read from a resource
$im = LeviImages::raster()->load(fopen('path/to/file.svg', 'r'));
LeviImages::optimizer()
// optimize file in place
LeviImages::optimizer()
->optimizeFile('path/to/file.png');
// create a new optimized image file
LeviImages::optimizer()
->optimizeFile('path/to/file.png', 'path/to/output.png');