我有一个图像被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>
Run Code Online (Sandbox Code Playgroud)
好吧,我不知道这是一个CMYK,我甚至不知道怎么说.然后我使用以下代码尝试转换:
$image= "$img.jpg";
$i = new Imagick($image);
$i->setImageColorspace(Imagick::COLORSPACE_SRGB);
$i->writeImage($image);
$i->destroy();
Run Code Online (Sandbox Code Playgroud)
它转换(现在被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();
Run Code Online (Sandbox Code Playgroud)