Crop image with PHP without libraries

0

I'm bringing some BD Mysql images of which some are horizontal and some vertical. I saw that there are some libraries that make this cut, but I wonder if there is any way to crop the image without the existence of libraries.

    
asked by anonymous 11.09.2017 / 18:03

1 answer

0

A basic example.

<?php
$im = imagecreatefrompng('example.png');
$size = min(imagesx($im), imagesy($im));
$im2 = imagecrop($im, ['x' => 0, 'y' => 0, 'width' => $size, 'height' => $size]);
if ($im2 !== FALSE) {
    imagepng($im2, 'example-cropped.png');
}
?>

At documentation you find information about.

    
11.09.2017 / 18:06