[BUG] OpenEXR PixelAspectRatio

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

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp

調査の方向性

提供されている ImageSpec::attribute と get_float_attribute の再現から始め、続いて ImageOutput::create/OpenEXR の書き込みパスと ImageInput::open のメタデータ読み戻しを追跡します。保存した画像内の PixelAspectRatio の string 値と float 値を比較します。再度開いた ImageSpec から読み取ったときに、両方の形式で値 2 が保持されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

The PixelAspectRatio metadata is not always propagated in the right way to an exr image whether it is set as a float or as a string.
It must be set as a float to be correctly propagated.
However, when reading back as a float in the image spec, just after the setting as a string, the returned value is correct.

To Reproduce
Switch the 2 commented lines of the following code between setting as a float and setting as a string.

	const std::string filename = "simple.exr";
	const int xres = 320, yres = 240, channels = 3;
	float pixels[xres * yres * channels] = { 0.5f };
	std::unique_ptr<OIIO::ImageOutput> out = OIIO::ImageOutput::create(filename);
	if (out)
	{
		std::cout << "save exr file ..." << std::endl;
		OIIO::ImageSpec spec_out(xres, yres, channels, OIIO::TypeDesc::FLOAT);

		float par = 2.0f;
		spec_out.attribute("PixelAspectRatio", par);
		//std::string par = "2.0";
		//spec_out.attribute("PixelAspectRatio", par);

		float par_read = spec_out.get_float_attribute("PixelAspectRatio", 4.0);
		std::cout << "PAR read in image spec before saving: " << par_read << std::endl;

		out->open(filename, spec_out);
		out->write_image(OIIO::TypeDesc::FLOAT, pixels);
		out->close();

		std::unique_ptr<OIIO::ImageInput> in(OIIO::ImageInput::open(filename));
		if (in)
		{
			std::cout << "read exr file metadata ..." << std::endl;

			OIIO::ImageSpec spec_in = in->spec();
			in->close();

			float parFromNewImage;
			spec_in.getattribute("PixelAspectRatio", OIIO::TypeDesc::FLOAT, &parFromNewImage);

			std::cout << "PAR read in image spec of saved image: " << parFromNewImage << std::endl;
		}
		else
		{
			std::cout << "cannot read the new exr file !!!" << std::endl;
		}
	}
	else
	{
		std::cout << "cannot create a new exr file !!!" << std::endl;
	}

Expected behavior
What we get when setting as a float (expected behavior):

save exr file ...
PAR read in image spec before saving: 2
read exr file metadata ...
PAR read in image spec of saved image: 2

Evidence
What we get when setting as a string:

save exr file ...
PAR read in image spec before saving: 2
read exr file metadata ...
PAR read in image spec of saved image: 1

Platform information:

  • OIIO branch/version: pick up from vcpkg
  • OS: Windows
  • C++ compiler: Visual Studio 2022
  • Any non-default build flags when you build OIIO:
主要言語
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 を短くまとめたダイジェスト。