[BUG] OpenEXR PixelAspectRatio

Aperta
#4,083 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
cpp

Direzione di ricerca

Inizia con la riproduzione fornita di ImageSpec::attribute e get_float_attribute, quindi segui il percorso di scrittura di ImageOutput::create/OpenEXR e la rilettura dei metadati tramite ImageInput::open. Confronta i valori string e float di PixelAspectRatio nell’immagine salvata; il lavoro è completo quando entrambe le forme preservano il valore 2 quando vengono lette dalla ImageSpec riaperta.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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:
Lingua principale
C++
Stelle
2.4k
Fork
727
Merge medio
4g 8h
PR unite (30g)
67

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AcademySoftwareFoundation/OpenImageIO

Tutte le issue di AcademySoftwareFoundation/OpenImageIO

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.