1. Go to this page and download the library: Download wiejakp/image-crop 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/ */
wiejakp / image-crop example snippets
$imagePath = 'image.jpeg';
$imageCrop = (new ImageCrop())
->setReader(JPEGReader::class)
->setWriter(JPEGWriter::class);
// load resource into a reader
$imageCrop->getReader()->loadFromPath($imagePath);
// perform cropping actions
$imageCrop->crop();
// skip images that appear to be empty
if (false === $imageCrop->isEmpty()) {
// save cropped image to the drive
$imageCrop->getWriter()->write();
// do stuff with $imageCrop->getData() or $imageCrop->getDataUri()
$anchor = \sprintf('<a href="%s">anchor</a>', $imageCrop->getDataUri());
...
}
$imageCrop = (new ImageCrop())
->setReader(BMPReader::class)
->setWriter(BMPWriter::class);
$imageCrop = (new ImageCrop())
->setReader(GIFReader::class)
->setWriter(GIFWriter::class);
$imageCrop = (new ImageCrop())
->setReader(JPEGReader::class)
->setWriter(JPEGWriter::class);
$imageCrop = (new ImageCrop())
->setReader(PNGReader::class)
->setWriter(PNGWriter::class);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.