Open In App

PHP | imagegetclip() Function

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

The ImagickDraw::imagegetclip() function is an inbuilt function in PHP which is used to get the current clipping rectangle, i.e. the area beyond the no of pixels will be drawn. Default clipping area is the whole image which can be customized using imagesetclip() function.

Syntax:

array ImagickDraw::imagegetclip( resource $image )

Parameters: This function accepts a single parameter $image which holds the image.

Return Value: This function returns array containing the clipping area.

Below examples illustrate the ImagickDraw::imagegetclip() function in PHP:

Example 1:




<?php
  
// Create an image
$im = imagecreatefrompng(
  
// Get the clipping area
print("<pre>".print_r(imagegetclip($im),
                         true)."</pre>");
?>


Output:

Array
(
    [0] => 0
    [1] => 0
    [2] => 666
    [3] => 183
)

Program 2:




<?php
  
// Create an image
$im = imagecreatefrompng(
  
// Set the clip area
imagesetclip($im,100, 100, 200, 300);
  
// Get the clipping area
print("<pre>".print_r(imagegetclip($im),
                         true)."</pre>");
?>


Output:

Array
(
    [0] => 100
    [1] => 100
    [2] => 200
    [3] => 183
)

Reference: https://www.php.net/manual/en/function.imagegetclip.php


Last Updated : 30 Jan, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads