Imagick::chopImage


wizard apg

REMOVES a region of an image and trim it.

This function accepts the dimension of image and chops the area and the dimension from where the image is to be trim.



<?php

bool 
public Imagick::chopImage(
                                            
int $width,
                                            
int $height,
                                            
int $x,
                                            
int $y
                                            
);
                               
?>

$width


The width of chopped area.



$height


The height of chopped area.



$x


The x origin of chopped area.



$y


The y origin of chopped area.





This function returns true on success.



  1 EXERCISE   

<?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?>">

 RESULT   

21ci751.jpg

width = 163
height = 88
x = 357
y = 223

img/results/21ci751.jpg apr