CakeFest 2024: The Official CakePHP Conference

Imagick::tintImage

(PECL imagick 2, PECL imagick 3)

Imagick::tintImage色ベクトルを画像の各ピクセルに適用する

説明

public Imagick::tintImage(mixed $tint, mixed $opacity, bool $legacy = false): bool

色ベクトルを画像の各ピクセルに適用します。 ベクトルの長さは、黒および白のときに 0、中間色のときに最大となります。 ベクトルの重み関数は f(x)=(1-(4.0*((x-0.5)*(x-0.5)))) です。

パラメータ

tint

opacity

戻り値

成功した場合に true を返します。

エラー / 例外

エラー時に ImagickException をスローします。

変更履歴

バージョン 説明
PECL imagick 2.1.0 色を表す文字列を最初のパラメータとして、 不透明度を表す浮動小数点数値を 2 番目のパラメータとして指定できるようになりました。 これまでのバージョンでは ImagickPixel オブジェクトしか指定できませんでした。

例1 Imagick::tintImage()

<?php
function tintImage($r, $g, $b, $a) {
$a = $a / 100;

$imagick = new \Imagick();
$imagick->newPseudoImage(400, 400, 'gradient:black-white');

$tint = new \ImagickPixel("rgb($r, $g, $b)");
$opacity = new \ImagickPixel("rgb(128, 128, 128, $a)");
$imagick->tintImage($tint, $opacity);
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo
$imagick->getImageBlob();
}

?>

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top