[BUG] CMYK is being saved as RGB on export

未关闭
#4,170 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
cpp

调研方向

首先使用提供的 oiiotool 命令重现该问题,并检查 C++ ImageInput/ImageOutput 的使用方式。比较导出前后的通道数和色彩空间元数据;完成标准是 CMYK 输入在调整大小并保存后仍保持为 CMYK,并配有适当的回归测试。

由索引模型根据 Issue 内容生成。

描述

Describe the bug

We employ the oiio library for reading and writing files before and after upscaling images. However, it saves CMYK images as RGB during export, although they appear correct before exporting.

OpenImageIO version and dependencies

OpenImageIO version 2.5.7.0-1 installed from ArchLinux repo

To Reproduce

We use the C++ API for using oiio in our code

The code to save is


std::unique_ptr<ImageInput> in = ImageInput::open(imagepath.c_str());
if (!in)
{
    std::cerr << "Could not open " << imagepath.c_str() << ", error = " << geterror() << "\n";
    errorOccurred = true;
    continue;
}

const ImageSpec &spec = in->spec();
w = spec.width;
h = spec.height;
c = spec.nchannels;

pixeldata = new unsigned char[w * h * c];
in->read_image(0, 0, 0, c, TypeDesc::UINT8, pixeldata);
in->close();

and the code to save image is:


std::unique_ptr<ImageOutput> out = ImageOutput::create(v.outpath.c_str());
if (!out)
{
    std::cerr << "Could not create output image, error = " << geterror() << "\n";
    continue;
}

std::unique_ptr<ImageInput> in = ImageInput::open(v.inpath.c_str());
if (!in)
{
    std::cerr << "Could not read input image, error = " << geterror() << "\n";
    continue; // Handle error appropriately
}
const ImageSpec &inputImageSpec = in->spec();
in->close(); // Close the input image

ImageSpec spec(v.outimage.w, v.outimage.h, v.outimage.elempack, TypeDesc::UINT8);

spec.extra_attribs = inputImageSpec.extra_attribs;
spec.extra_attribs.attribute("XResolution", 300);
spec.extra_attribs.attribute("YResolution", 300);
spec.extra_attribs.attribute("Exif:PixelXDimension", v.outimage.w);
spec.extra_attribs.attribute("Exif:PixelYDimension", v.outimage.h);
std::cout << "\n\nNew Color Space: " << spec.extra_attribs.get_string("ICCProfile:color_space") << "\n\n";

success = out->open(v.outpath.c_str(), spec);
if (!success)
{
    std::cerr << "Could not open output image, error = " << out->geterror() << "\n";
    continue;
}
success = out->write_image(TypeDesc::UINT8, v.outimage.data);
if (!success)
{
    std::cerr << "Could not write output image, error = " << out->geterror() << "\n";
    continue;
}

out->close();

oiiotool code to replicate is

oiiotool output/cmyk_original.jpg --resize 500x333 --metamerge -o cmyk1.jpg

Evidence

The information is there before saving
image

But after saving the image file
image

The Original Photo
cmyk_original

The processed photo
cmyk

主要语言
C++
星标
2.4k
派生
727
平均合并
4 天 8 小时
30 天内合并 PR
67

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

AcademySoftwareFoundation/OpenImageIO 的其他 Issue

查看 AcademySoftwareFoundation/OpenImageIO 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。