略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Imagick::exportImagePixels

2024-04-28

Imagick::exportImagePixels

(PECL imagick 2 >=2.3.0, PECL imagick 3)

Imagick::exportImagePixelsExports raw image pixels

说明

public Imagick::exportImagePixels(
    int $x,
    int $y,
    int $width,
    int $height,
    string $map,
    int $STORAGE
): array

Exports image pixels into an array. The map defines the ordering of the exported pixels. The size of the returned array is width * height * strlen(map). 此方法在Imagick基于ImageMagick 6.4.7以上版本编译时可用。

参数

x

X-coordinate of the exported area

y

Y-coordinate of the exported area

width

Width of the exported aread

height

Height of the exported area

map

Ordering of the exported pixels. For example "RGB". Valid characters for the map are R, G, B, A, O, C, Y, M, K, I and P.

STORAGE

Refer to this list of pixel type constants

返回值

Returns an array containing the pixels values.

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Using Imagick::exportImagePixels()

Export image pixels into an array

<?php

/* Create new object */
$im = new Imagick();

/* Create new image */
$im->newPseudoImage(00"magick:rose");

/* Export the image pixels */
$pixels $im->exportImagePixels(101022"RGB"Imagick::PIXEL_CHAR);

/* Output */
var_dump($pixels);
?>

以上例程会输出:

array(12) {
  [0]=>
  int(72)
  [1]=>
  int(64)
  [2]=>
  int(57)
  [3]=>
  int(69)
  [4]=>
  int(59)
  [5]=>
  int(43)
  [6]=>
  int(124)
  [7]=>
  int(120)
  [8]=>
  int(-96)
  [9]=>
  int(91)
  [10]=>
  int(84)
  [11]=>
  int(111)
}
add a noteadd a note

User Contributed Notes 1 note

up
1
P S
1 month ago
These are the letters for the map:

R = red
G = green
B = blue
A = alpha (0 is transparent)
O = alpha (0 is opaque)
C = cyan
Y = yellow
M = magenta
K = black
I = intensity (for grayscale)
P = pad

官方地址:https://www.php.net/manual/en/imagick.exportimagepixels.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3