getQuantumDepth 的運作方式很像其他的「Depth」函式,也很像 getQuantumRange 函式。和 Depth 函式一樣,它會傳回一個值,表示儲存唯一色彩值的位元數 -- 16 位元 = 2^16 個唯一色彩,即 65,535(二進位計算從「0」開始,與十進位的「1」相反)。和 getQuantumRange 函式一樣,它會傳回一個包含兩個值的陣列,一個是長整數 (「quantumDepthLong」),另一個是字串 (「quantumDepthLong」)。除了變數型別之外,唯一的區別是字串版本的前面會加上「Q」。
以下是一些範例程式碼和結果,假設有一張色彩、BMP 檔案格式的照片,尺寸為 600x450 像素...
<?php
$imagick_type = new Imagick();
$file_to_grab = "image_workshop_directory/test.bmp";
$file_handle_for_viewing_image_file = fopen($file_to_grab, 'a+');
$imagick_type->readImageFile($file_handle_for_viewing_image_file);
$imagick_type_quantum_depth = $imagick_type->getQuantumDepth();
print("<pre>");
print_r($imagick_type_quantum_depth);
print("</pre>");
?>
輸出
陣列
(
[quantumDepthLong] => 16
[quantumDepthString] => Q16
)