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.
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.
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.