parent root
PHP: Imagick::setImageType - Manual

Imagick::setImageType

(PECL imagick 2.0.0)

Imagick::setImageTypeSets the image type

Description

Imagick::setImageType ( int $image_type ) : bool

Sets the image type.

Parameters

image_type

Return Values

Returns TRUE on success.

add a noteadd a note

User Contributed Notes 2 notes

up
1
lee dot traynor at skeptic dot de
7 years ago
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

?>
up
0
quickshiftin at gmail dot com
4 years ago
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
To Top
parent root