0

I have got this image :

enter image description here

And i need to crop the top and bottom, so i will get this :

enter image description here

I was searching for a while, but did not find a solution, it needs to be done in PHP.

Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46
Tadeáš Jílek
  • 2,813
  • 2
  • 19
  • 32

1 Answers1

1

You can use imagecrop() method to crop any image as follows:

$filename = 'test.JPG';
    $image = imagecreatefromjpeg($filename );
    $x_size = getimagesize($filename)[0];
    $y_size = getimagesize($filename)[1];
    $crop_measure = min($x_size, $y_size);
    header('Content-Type: image/jpeg');
    $crop_array = array('x' =>0 , 'y' => 0, 'width' => $crop_measure, 'height'=> $crop_measure);
    $thumb_image = imagecrop($image, $crop_array);
PHP Geek
  • 3,949
  • 1
  • 16
  • 32