Syntax:array Imagick::exportImagePixels ($x, $y, $width, $height, $map, $STORAGE)
Parameters:This function takes six parameters as above and described below:
- $x:contains x-coordinate of the exported area.
- $y:contains the y-coordinate of the exported area.
- $width:contains the width of the exported area .
- $height:contains the height of the exported area.
- $map:contains the order of the exported pixels. For example, "RGB". Valid map symbols are R, G, B, A, O, C, Y, M, K, I, and P.
- $STORAGE:contains pixel type constants.
Returned value:this function returns an array containing pixel values.
Program :
// Create a new Imagick object
$image
=
new
Imagick();
// Use the newPseudoImage() function
// create a new image
$image
-> newPseudoImage (0, 0,
"magick: rose"
);
// Using the exportImagePixels() function
// export image pixels
$pixels
=
$image
-> exportImagePixels (5, 5, 3, 3,
" RGB "
, Imagick::PIXEL_CHAR);
// Show output array
var_dump (
$pixels
);
?>
Output:array (27) {[0] = > int (51) [1] = > int (47) [2] = > int (44) [3] = > int (50) [4] = > int (45) [5] = > int (42) [6] = > int (45) [7] = > int (42) [8] = > int (43) [9] = > int (58) [10] = > int (50) [11] = > int (46) [12] = > int (56) [13] = > int (48) [14] = > int (45) [15] = > int (51) [16] = > int (46) [17] = > int (44) [18] = > int (66) [19] = > int (58) [20] = > int (56) [21] = > int (65) [22] = > int (57) [23] = > int (53) [24] = > int (61) [25] = > int (55) [26] = > int (51)}
Link: https://www .php.net / manual / en / imagick.exportimagepixels.php