claviska / SimpleImage

A PHP class that makes working with images and GD as simple as possible.
MIT License
1.38k stars 382 forks source link

Imagecropauto feature #289

Open Nicero opened 2 years ago

Nicero commented 2 years ago

Does SimpleImage supports imagecropauto (as called in GD) to remove white (or black, etc) background?

$cropped = imagecropauto($image, IMG_CROP_WHITE);
claviska commented 2 years ago

Not presently, but I'd accept a PR for it.

BodyEND commented 2 years ago

For croping i am using this function

public function cropImage($cropType=IMG_CROP_DEFAULT) {
    $croppedImage = imagecropauto($this->image, $cropType);
    if ($croppedImage!== false) { 
      imagedestroy($this->image); 
      $this->image = $croppedImage; 
    }
    return $this;
  }