這是一個您可以對影像執行的巧妙操作,作為藝術化處理的一部分,可能與其他 ImageMagick 效果(例如 PosterizeImage 和 OilPaintImage)結合使用。 SolarizeImage 會將影像的整個色譜向紅色偏移——白色直接推到紅色,藍色推到綠色,等等。這主要是一種迷幻效果。「閾值」參數可選,它實際上只是您希望在影像中呈現多少這種效果。最小值為 0,使用負數則預設為 0。最大值為量子閾值。您可以透過 ImageMagick 函式 getQuantumRange 取得此值。在我的 PHP 安裝中,該值設定為 65535 (2^16)。高於量子範圍的值會預設為量子範圍。使用此函式處理且閾值為 0 的影像會產生最大效果,而閾值為最大值的影像則完全沒有任何變化。
現在是一個簡單的程式碼示範
<?php
$file_to_grab_with_location = "graphics_engine/image_workshop_directory/test.bmp";
$imagick_type = new Imagick();
$file_handle_for_viewing_image_file = fopen($file_to_grab_with_location, 'a+');
$imagick_type->readImageFile($file_handle_for_viewing_image_file);
$imagick_type->solarizeImage(30000);
$file_to_save_with_location = "graphics_engine/image_workshop_directory/test_new.bmp";
$file_handle_for_saving_image_file = fopen($file_to_save_with_location, 'a+');
$imagick_type->writeImageFile($file_handle_for_saving_image_file);
?>