[BUG] CMYK is being saved as RGB on export

オープン
#4,170 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
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時間
マージ済み PR(30日)
67

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

AcademySoftwareFoundation/OpenImageIO のほかの issue

AcademySoftwareFoundation/OpenImageIO の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。