PHPのお勉強!

PHP TOP

Imagick::transformImageColorspace

(PECL imagick 3)

Imagick::transformImageColorspaceTransforms an image to a new colorspace

説明

public Imagick::transformImageColorspace(int $colorspace): bool

Transforms an image to a new colorspace.

パラメータ

colorspace

The colorspace the image should be transformed to, one of the COLORSPACE constants e.g. Imagick::COLORSPACE_CMYK.

戻り値

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

例1 Imagick::transformImageColorspace() example

Transforms an image to a new colorspace, and then extracts a single channel so that the individual channel values can be viewed.

<?php
function transformImageColorspace($imagePath, $colorSpace, $channel) {
$imagick = new \Imagick(realpath($imagePath));
$imagick->transformimagecolorspace($colorSpace);
//channel should be one of the channel constants e.g. \Imagick::CHANNEL_BLUE
$imagick->separateImageChannel($channel);
header("Content-Type: image/jpg");
echo
$imagick->getImageBlob();
}
?>

参考

add a note

User Contributed Notes 1 note

up
0
A.Ross
9 years ago
This SO question and answer might help clarify why transformImageColorspace is useful: http://stackoverflow.com/questions/29296779/convert-pdf-with-transparency-and-cmyk-to-jpg

Also, there's a Github issue here that explains the difference between transformImageColorspace and setImageColorspace: https://github.com/rmagick/rmagick/pull/75