This is a small set of image croppers that I created for testing automated cropping.
This little project includes three functional image cropers:
This is the most basic of cropping techniques:
This class finds the a position in the picture with the most "energy" in it. Energy (or entropy) in images are defined by 'edginess' in the image. For example a image of the sky have low edginess and an image of an anthill has very high edginess.
Energy is in this case calculated like this
Crop balanced is a variant of CropEntropy where I tried to the cropping a bit more balanced.
Crop face uses PHP Facedetect Extension (which uses OpenCV).
In details, the FaceCrop uses Entropy Crop but puts blocking "limits" on the faces. If the program faces two limits, we let the entropy decide the best crop.
$center = new \stojg\crop\CropCenter($filepath);
$croppedImage = $center->resizeAndCrop($width, $height);
$croppedImage->writeimage('assets/thumbs/cropped-center.jpg');