略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Imagick::getQuantumDepth

2024-12-21

Imagick::getQuantumDepth

(PECL imagick 2, PECL imagick 3)

Imagick::getQuantumDepthGets the quantum depth

说明

public static Imagick::getQuantumDepth(): array

Returns the Imagick quantum depth.

参数

此函数没有参数。

返回值

Returns an array with "quantumDepthLong" and "quantumDepthString" members.

错误/异常

错误时抛出 ImagickException。

add a noteadd a note

User Contributed Notes 1 note

up
1
holdoffhunger at gmail dot com
10 years ago
The getQuantumDepth works much like the other "Depth" functions and much like the getQuantumRange function.  Like the Depth functions, it returns a value indicating the number of bits to store the unique color values -- 16-bit = 2^16 unique colors, which is 65,535 (counting starts at '0' in binary, as opposed to '1' in decimal).  Like the getQuantumRange function, it returns an array with two values, one being a long integer ('quantumDepthLong') and the other being a string ('quantumDepthLong').  The only difference, besides the variable types, is that the string version has a 'Q' prefixed to it.

Here's some sample code and the results, given a color, BMP file photograph that is 600x450 pixels...

<?php

           
// Author: holdoffhunger@gmail.com
   
        // Imagick Type
        // ---------------------------------------------

   
$imagick_type = new Imagick();
   
       
// Open File
        // ---------------------------------------------
       
   
$file_to_grab = "image_workshop_directory/test.bmp";
   
   
$file_handle_for_viewing_image_file = fopen($file_to_grab, 'a+');
   
       
// Grab File
        // ---------------------------------------------

   
$imagick_type->readImageFile($file_handle_for_viewing_image_file);
   
       
// Get Quantum Depth
        // ---------------------------------------------
       
   
$imagick_type_quantum_depth = $imagick_type->getQuantumDepth();
   
       
// Print Results
        // ---------------------------------------------

   
print("<pre>");
   
print_r($imagick_type_quantum_depth);
    print(
"</pre>");

?>

Output:

Array
(
    [quantumDepthLong] => 16
    [quantumDepthString] => Q16
)

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

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