AcademySoftwareFoundation / OpenImageIO

Reading, writing, and processing images in a wide variety of file formats, using a format-agnostic API, aimed at VFX applications.

Home Page:https://openimageio.readthedocs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] When using ImageBuf, this file reports a divide-by-zero exception error. Please take a look

cool2528 opened this issue · comments

commented

Describe the bug

When using ImageBuf, this file reports a divide-by-zero exception error. Please take a look
This is a sample file.
XPPen_new_logo.zip

OpenImageIO version and dependencies
v2.4.13.0

To Reproduce

Execute the following code:

	ImageCache *cache = ImageCache::create ()
	auto inp = ImageBuf(path, cache);
	if (inp.has_error()) {
	std::cout << "parser: open image error: "  << inp.geterror() << std::endl;
	return nullptr;
}

Evidence
373c84ac874a40132f3c7c566b4fb2c

@lgritz @cool2528 Can I take up this issue?

commented

@lgritz I found that the issue is consistently reproducible when using the autotile attribute. This is a new test code. The previous code I provided might not exhibit this issue in the new version. I apologize for this.

#include <iostream>
#include "OpenImageIO/imagebuf.h"
#include "OpenImageIO/imageio.h"
#include "OpenImageIO/imagecache.h"

int main()
{
	OIIO::ImageCache* cache = nullptr;
	cache = OIIO::ImageCache::create(false);
	cache->attribute("autotile", 64);
	std::thread t([&]
	{
			OIIO::ImageBuf img(R"(C:\Users\Administrator\Desktop\bug\XPPen_new_logo\XPPen_new_logo.ico)", cache);
			if (img.has_error())
			{
				std::cerr << "Error reading image  error " << img.geterror() << std::endl;
				return;
			}
			const auto& spec = img.spec();

			std::cout << "image width " << spec.width << "  image height " << spec.height << " channel " << spec.nchannels << std::endl;
	});
	t.join();
	OIIO::ImageCache::destroy(cache);
	return 0;
}