Search code examples
phpimagepngcrop

remove transparent area (crop transparent) from border using php


Anybody who help me to solve a problem.
i have image which have transparent area left and right How to remove transparent area from picture using php.
crop(remove) transparent area from picture
Note : Gray color is Transparent actually. enter image description here

i want convert into this
enter image description here


Solution

  • Checkout PHPs imagecropauto:

    resource imagecropauto ( resource $image [, int $mode = -1 [, float $threshold = .5 [, int $color = -1 ]]] )
    

    especially:

    IMG_CROP_TRANSPARENT: Crops out a transparent background.

    Documentation