<?php
bool public Imagick::chopImage(
int $width,
int $height,
int $x,
int $y
);
?>
<?php
// Run this exercise several times
$path = PATH2IMGW . '/others/21.jpg';
$s = getimagesize($path);
$str1img = 'img/results/21ci751.jpg';
$imagick = new Imagick($path);
$w = $s[0];
$h = $s[1];
$width = mt_rand(0, $w);
$height = mt_rand(0, $h);
$x = mt_rand(0, $w);
$y = mt_rand(0, $h);
$imagick->chopImage($width, $height, $x, $y);
$imagick = $imagick->getImageBlob();
$img = imagecreatefromstring($imagick);
imagejpeg($img, $str1img);
echo basename($str1img) ; ?>
<br><br>
<img src="<?php echo $str1img; ?>"
alt="<?php echo $str1img; ?>"
title="<?php echo $str1img; ?>">