Tip:
<?php
$image->contrastImage(1); //Increase contrast once
$image->contrastImage(1); //Increase contrast more
$image->contrastImage(1); //Increase contrast even more
$image->contrastImage(0); //Decrease contrast once
$image->contrastImage(0); //Decrease contrast more
$image->contrastImage(0); //Decrease contrast even more
//This could be made into a function like this:
public function contrast($level) {
$level = (int)$level;
if ($level < -10) {
$level = -10;
} else if ($level > 10) {
$level = 10;
}
if ($level > 0) {
for ($i = 0; $i < $level; $i++) {
$this->image->contrastImage(1);
}
} else if ($level < 0) {
for ($i = $level; $i > 0; $i--) {
$this->image->contrastImage(0);
}
}
}
?>
Imagick::contrastImage
(PECL imagick 2.0.0)
Imagick::contrastImage — 画像のコントラストを変更する
説明
bool Imagick::contrastImage
( bool
$sharpen
)画像の中の暗めの部分と明るめの部分の輝度の差を強調します。 sharpen に 0 以外を指定すると画像のコントラストを上げ、 0 を指定するとコントラストを下げます。
パラメータ
-
sharpen -
シャープ値。
返り値
成功した場合に TRUE を返します。
エラー / 例外
エラー時に ImagickException をスローします。
xyking
16-Apr-2010 08:14
goekar at msn dot com
08-Aug-2007 05:33
<?
$image = new Imagick('test.jpg'); // open image file
$image->contrastImage(9); // 0 - 9
$image->writeImage('test2.jpg'); //save image
?>
