PHP imagick 将图像从 CMYK 转换为 RGB 反转图像

PHP imagick converting image from CMYK to RGB inverts image

我有一张图片被 eBay 拒绝 API 因为:

 <ShortMessage>Source picture uses an unsupported colorspace.</ShortMessage>
    <LongMessage>Pictures with a CMYK colorspace are not supported; source pictures must use a RGB colorspace compatible with all web browsers supported by eBay. Submit pictures created using a camera or scanner set to save images with RGB color.</LongMessage>

好吧,我不知道这是 CMYK,我什至不确定如何分辨。然后我使用以下代码尝试转换:

$image= "$img.jpg";
$i = new Imagick($image);
$i->setImageColorspace(Imagick::COLORSPACE_SRGB);
$i->writeImage($image);
$i->destroy();

它会转换(现在被 eBay 接受),但它也会反转图片的颜色。为什么要这样做,我应该使用另一个 COLORSPACE 吗?

谢谢。

setImageColorSpace 方法不适用于现有图像 - 它仅适用于新图像(例如 $imagick->newPseudoImage(100, 100, "xc:gray");

transformImageColorSpace 方法是用于更改现有图像色彩空间的正确方法。

$image= "$img.jpg";
$i = new Imagick($image);
$i->transformImageColorspace(Imagick::COLORSPACE_SRGB);
$i->writeImage($image);
$i->destroy();