PHP |想象一下 getImageProperties()函数
Imagick::getImageProperties()函数是PHP中的一个内置函数,用于获取图像属性。
句法:
array Imagick::getImageProperties( string $pattern, string $includes_values )
参数:该函数接受上面提到的两个参数,如下所述:
- $pattern:它指定属性名称的模式。默认值为 *,它返回所有属性。
- $includes_values:它指定是否只返回属性名称。其默认值为 TRUE。如果为 FALSE,则只返回属性名称。
返回值:此函数返回一个包含图像属性或仅包含属性名称的数组。
下面的程序说明了PHP中的Imagick::getImageProperties()函数:
方案一:
php
setImageProperty('property1', 'value1');
$imagick->setImageProperty('property2', 'value2');
$imagick->setImageProperty('hello', 'world');
// Get the Image Profiles without values starting from "pro"
$properties = $imagick->getImageProperties("pro*", false);
print("".print_r($properties, true)."
");
?>
php
setImageProperty('property1', 'value1');
$imagick->setImageProperty('property2', 'value2');
// Get the Image Profiles
$properties = $imagick->getImageProperties("*");
print("".print_r($properties, true)."
");
?>
输出:
Array
(
[0] => property1
[1] => property2
)
方案二:
PHP
setImageProperty('property1', 'value1');
$imagick->setImageProperty('property2', 'value2');
// Get the Image Profiles
$properties = $imagick->getImageProperties("*");
print("".print_r($properties, true)."
");
?>
输出:
Array
(
[date:create] => 2019-11-21T22:32:52+05:00
[date:modify] => 2019-11-21T22:32:52+05:00
[png:cHRM] => chunk was found (see Chromaticity, above)
[png:gAMMA] => gamma=0.45455 (See Gamma, above)
[png:IHDR.bit-depth-orig] => 8
[png:IHDR.bit_depth] => 8
[png:IHDR.color-type-orig] => 6
[png:IHDR.color_type] => 6 (RGBA)
[png:IHDR.interlace_method] => 0 (Not interlaced)
[png:IHDR.width, height] => 667, 184
[png:pHYs] => x_res=3780, y_res=3780, units=1
[png:sRGB] => intent=0 (Perceptual Intent)
[png:text] => 1 tEXt/zTXt/iTXt chunks were found
[property1] => value1
[property2] => value2
[Software] => Adobe ImageReady
)
参考: https://www. PHP.net/manual/en/imagick.getimageproperties。 PHP