文字

Imagick::transformImageColorspace

(No version information available, might only be in Git)

Imagick::transformImageColorspaceTransforms an image to a new colorspace.

说明

bool Imagick::transformImageColorspace ( int $colorspace )

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 , 或者在失败时返回 FALSE

范例

Example #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 ();
}
?>

参见

  • Imagick::setColorSpace() - Set colorspace

范例

Example #2 Imagick::transformImageColorspace()

<?php
function  transformImageColorspace ( $imagePath $colorSpace $channel ) {
    
$imagick  = new \ Imagick ( realpath ( $imagePath ));
    
$imagick -> transformimagecolorspace ( $colorSpace );
    
$imagick -> separateImageChannel ( $channel );
    
header ( "Content-Type: image/jpg" );
    echo 
$imagick -> getImageBlob ();
}

?>

用户评论:

[#1] A.Ross [2015-04-15 07:31:58]

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

上一篇: 下一篇: