<?php
bool public Imagick::cropImage(
int $width,
int $height,
int $x,
int $y
);
?>
<?php
// Run this exercise several times
// For each new time, a new image will be shown
$img1 = new imagick(PATH2IMGW . '/jpg/aa.jpg');
$str1img = 'img/results/6aa new.jpg';
// Randon numbers
$w1 = mt_rand(10, $img1->getImageWidth());
$h1 = mt_rand(10, $img1->getImageHeight());
$x1 = $w1;
$y1 = $h1;
// You should try other values
$img1->cropImage($w1, $h1, $x1, $y1);
$strg = $img1->getImageBlob();
// Reads the STRING of getImageBlob() with the PHP GD library
$img = imagecreatefromstring($strg);
imagejpeg($img, $str1img);
echo basename($str1img); ?>
<br><br>
<img src="<?php echo $str1img; ?>"
alt="<?php echo $str1img; ?>"
title="<?php echo $str1img; ?>">