image
image copied to clipboard
Feature Request: Image Auto Crop
Hello,
It would be nice to have the option to auto crop images with imagecropauto (GD) / trimImage (imagick)
@petsoukos, It's pretty easy to do this as long as the option is not available.
In GD:
$img = ImageManagerStatic::make(PATH_TO_ORINGIN_IMAGE);
$croppedImg = imagecropauto($img->getCore(), IMG_CROP_SIDES);
$croppedImg = ImageManagerStatic::make($cropedImg);
Then use $croppedImg
as pleased.
I suppose with imagick is similar
@petsoukos, It's pretty easy to do this as long as the option is not available.
In GD:
$img = ImageManagerStatic::make(PATH_TO_ORINGIN_IMAGE); $croppedImg = imagecropauto($img->getCore(), IMG_CROP_SIDES); $croppedImg = ImageManagerStatic::make($cropedImg);
Then use
$croppedImg
as pleased.I suppose with imagick is similar
Even better, with less resources:
$img = ImageManagerStatic::make(PATH_TO_ORINGIN_IMAGE);
$img->setCore(imagecropauto($img->getCore(), IMG_CROP_SIDES));
@jdgrieco Thank you for taking the time to reply! I did not have time to investigate a solution even since way back when I posted the feature request. I think I can implement it, maybe even do a PR.
Use the trim() method for "auto cropping" solid color background sections.