PHP 日本研討會 2024

Imagick::getQuantumDepth

(PECL imagick 2, PECL imagick 3)

Imagick::getQuantumDepth取得量子深度

描述

public static Imagick::getQuantumDepth(): array

傳回 Imagick 量子深度。

參數

此函式沒有任何參數。

傳回值

傳回一個陣列,其中包含 "quantumDepthLong""quantumDepthString" 成員。

錯誤/例外

發生錯誤時拋出 ImagickException。

新增筆記

使用者貢獻筆記 1 則筆記

holdoffhunger at gmail dot com
12 年前
getQuantumDepth 的運作方式很像其他的「Depth」函式,也很像 getQuantumRange 函式。和 Depth 函式一樣,它會傳回一個值,表示儲存唯一色彩值的位元數 -- 16 位元 = 2^16 個唯一色彩,即 65,535(二進位計算從「0」開始,與十進位的「1」相反)。和 getQuantumRange 函式一樣,它會傳回一個包含兩個值的陣列,一個是長整數 (「quantumDepthLong」),另一個是字串 (「quantumDepthLong」)。除了變數型別之外,唯一的區別是字串版本的前面會加上「Q」。

以下是一些範例程式碼和結果,假設有一張色彩、BMP 檔案格式的照片,尺寸為 600x450 像素...

<?php

// 作者:holdoffhunger@gmail.com

// Imagick 型別
// ---------------------------------------------

$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
)
To Top