Yes, it is possible, as I do it:
$imgSrc = "image.jpg";
list($width, $height) = getimagesize($imgSrc);
$myImage = imagecreatefromjpeg($imgSrc);
if ($width > $height)
{
$y = 0;
$x = ($width - $height) / 2;
$smallestSide = $height;
}
else
{
$x = 0;
$y = ($height - $width) / 2;
$smallestSide = $width;
}
$thumbSize = 100;
$thumb = imagecreatetruecolor($thumbSize, $thumbSize);
imagecopyresampled($thumb, $myImage, 0, 0, $x, $y, $thumbSize, $thumbSize, $smallestSide, $smallestSide);
header('Content-type: image/jpeg');
imagejpeg($thumb);
This is not a verry light operation, like the others, I also recommend that you save the sketch after creating it in your file system.
You might want to check out the PHP GD library .
source
share