©
本文檔使用 php中文網手册 發布
(PECL imagick 2.0.0)
Imagick::setImageType — Sets the image type
$image_type
)Sets the image type.
image_type
成功时返回 TRUE
。
[#1] quickshiftin at gmail dot com [2014-10-04 18:29:55]
The cleaner way to set the type to grayscale is to use the Imagick class constant.
$oBw = new \Imagick($sSourceImage);
$oBw->setImageType(\Imagick::IMGTYPE_GRAYSCALE);
I've found this to be a rather harsh 'convert to grayscale' approach. Fred's color2gray script works much better, but it's written in Bash. Time to get it ported over lol
http://www.fmwconcepts.com/imagemagick/color2gray/index.php
[#2] lee dot traynor at skeptic dot de [2011-10-19 13:37:24]
This function can be used to desaturate an image, i.e. to convert a coloured image into a greyscale:
<?php
$im = new Imagick ("image.jpg");
$im->setImageType (2);
//is now in 256 shades of grey
?>