imagesetclip 


gd apg

SETS the clipping rectangle, i.e. the area beyond which no pixels will be drawn.

This function is only available as of PHP 7.2.0





This function returns TRUE on success or FALSE on failure.



<?php

bool imagesetclip 
GdImage $image
                                         
int $x1
                                         
int $y1
                                         
int $x2
                                         
int $y2 )

where,

$image The image identifier

$x1 
The x-coordinate of the upper left corner 

$y1 
The y-coordinate of the upper left corner

$x2 
The x-coordinate of the lower right corner 

$y2 
The y-coordinate of the lower right corner

?>
 

  $imageage   


The image identifier.



  $x1   


The x-coordinate of the upper left corner.



  $y1   


The y-coordinate of the upper left corner .



  $x2   


The x-coordinate of the lower right corner.



  $y2   


The y-coordinate of the lower right corner.



  1 EXERCISE   

<?php

echo 'PHP VERSION: ' PHP_VERSION '<br><br>';

$img01 'png/PNG 076 01.png';

$rct01 'png/PNG 076 01 imagesetclip.png';

echo 
$img01?> 
<br><br><img src="<?php echo  
$img01?>" alt="<?php echo $img01?>" width="400"><br><br>  

<?php

$id_im01 
imagecreatefrompng($img01);

$x01a 230;
$y01a 123;

$x01b 360;
$y01b 230;

$white imagecolorallocate($id_im0100255);

$bool01 imagesetclip($id_im01
                                     
$x01a$y01a$x01b$y01b);

if(
$bool01 == TRUE)
{
imagerectangle($id_im01
                          
$x01a$y01a$x01b$y01b$white);

imagepng($id_im01$rct01);    

echo 
$rct01?> 
<br><br><img src="<?php echo  
$rct01?>" alt="<?php echo $rct01?>" width="400">
<?php
}
?>  


 RESULT   

PNG 076 01.png

PNG 076 01.png apr

PNG 076 01 imagesetclip.png

PNG 076 01 imagesetclip.png apr