PHP ImageMagick setColorspace无法正常工作 [英] PHP ImageMagick setColorspace not working

查看:429
本文介绍了PHP ImageMagick setColorspace无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过使用以下代码更改颜色空间将图像转换为黑白图像:

I'm trying to convert an image to black and white by altering the colorspace with this code:

$im = new Imagick('image.png');
$im->setImageColorspace(Imagick::COLORSPACE_GRAY);
$im->writeImage('out.png');

但是在此代码之后,图像没有明显的变化(out.png和image.png看起来难以区分)。有关为什么会这样的想法吗?这是转换和成像到B& W的正确方法吗?还有其他方法吗?

However after this code, there is no visible change to the image (out.png and image.png look indistinguishable). Any thoughts on why this might be? Is this the proper method to convert and image to B&W? Are there any other methods?

我也试过setColorspace(Imagick :: COLORSPACE_GRAY);结果相同。

I've also tried setColorspace(Imagick::COLORSPACE_GRAY); with the same results.

这是我正在使用的软件:

Here's the software I'm using:

ImageMagick 6.6.9-7
PHP 5.3.10-1ubuntu3.1
Server version: Apache/2.2.22 (Ubuntu)

编辑:一些额外的信息

我也尝试过转换到其他颜色空间(特别是CMY和CMYK)和注意到没有视觉差异。

I've also tried converting to other colorspaces (specifically CMY and CMYK) and noticed no visual difference then either.

推荐答案

作为替代方案,您可以尝试 $ im-> modulateImage(100,0,100); 而不是 setImageColorspace()

As an alternative, you can try $im->modulateImage(100,0,100); instead of setImageColorspace()

希望这会有所帮助!

这篇关于PHP ImageMagick setColorspace无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆