PHP 8.3.4 Released!

Imagick::setColorspace

(PECL imagick 3)

Imagick::setColorspace色空間を設定する

説明

public Imagick::setColorspace(int $COLORSPACE): bool

オブジェクトのグローバル色空間の値を設定します。 このメソッドは、ImageMagick バージョン 6.5.7 以降で Imagick をコンパイルした場合に使用可能です。

パラメータ

COLORSPACE

COLORSPACE 定数 のひとつ。

戻り値

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

エラー / 例外

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

add a note

User Contributed Notes 2 notes

up
0
simonjjarrett at gmail dot com
3 years ago
This method has to be called BEFORE any files are loaded into the Imagick object.

By default, Imagick will incorrectly read CMYK PDFs - it will read each channel as a greyscale page resulting in 4 times the number of pages. By specifying the desired colorspace (usually SRGB) before reading the file, GhostScript will automatically convert it.

<?php
$im
= new Imagick();

// set the sampling resolution
$im->setResolution(200,200);

// set the desired format
$im->SetColorspace(Imagick::COLORSPACE_SRGB);

$im->readimage($file['tmp_name']);
?>
up
-2
T
9 years ago
Right now this function doesn't appear to do anything, ref: http://stackoverflow.com/q/10739822/2685496

As mentioned in the answer, modulateImage works fine as a replacement for converting to gray scale.

<?php

$image
= new Imagick("input.jpg");

$image->modulateImage(100, 0, 100);

$image->writeImage("output.jpg");

$image->clear();

?>
To Top