Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: read_image failing due to incorrect signature for OIIO read_image #1252

Open
n-garc opened this issue Mar 17, 2024 · 1 comment
Open
Labels

Comments

@n-garc
Copy link

n-garc commented Mar 17, 2024

Description

When attempting to read an image with read_image(path), I am getting an incorrect signature error from OpenImageIO (v2.5.9). The error seems to be originating from colour/io/image.py:278. The signature was changed in 2.1.19.0 in response to this bug report AcademySoftwareFoundation/OpenImageIO/issues/2676.

Code for Reproduction

path = '/home/user/src_dir/test_images/image1.jpeg'
image1 = colour.read_image(path)

Exception Message

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[14], line 2
      1 path = '/home/user/src_dir/test_images/image1.jpeg'
----> 2 image1 = colour.read_image(path)

File ~/anaconda3/envs/pixelsorting/lib/python3.12/site-packages/colour/io/image.py:444, in read_image(path, bit_depth, method, **kwargs)
    441 if method == "openimageio":  # pragma: no cover
    442     kwargs = filter_kwargs(function, **kwargs)
--> 444 return function(path, bit_depth, **kwargs)

File ~/anaconda3/envs/pixelsorting/lib/python3.12/site-packages/colour/utilities/common.py:1086, in required.<locals>.wrapper.<locals>.wrapped(*args, **kwargs)
   1083 for requirement in requirements:
   1084     _REQUIREMENTS_TO_CALLABLE[requirement](raise_exception=True)
-> 1086 return function(*args, **kwargs)

File ~/anaconda3/envs/pixelsorting/lib/python3.12/site-packages/colour/io/image.py:278, in read_image_OpenImageIO(path, bit_depth, attributes)
    270 specification = image_input.spec()
    272 shape = (
    273     specification.height,
    274     specification.width,
    275     specification.nchannels,
    276 )
--> 278 image = image_input.read_image(bit_depth_specification.openimageio)
    279 image_input.close()
    281 image = np.array(image, dtype=bit_depth_specification.numpy).reshape(shape)

TypeError: read_image(): incompatible function arguments. The following argument types are supported:
    1. (self: OpenImageIO.OpenImageIO.ImageInput, subimage: int, miplevel: int, chbegin: int, chend: int, format: OpenImageIO.OpenImageIO.TypeDesc = <TypeDesc 'float'>) -> object
    2. (self: OpenImageIO.OpenImageIO.ImageInput, chbegin: int, chend: int, format: OpenImageIO.OpenImageIO.TypeDesc = <TypeDesc 'float'>) -> object
    3. (self: OpenImageIO.OpenImageIO.ImageInput, format: OpenImageIO.OpenImageIO.TypeDesc = <TypeDesc 'float'>) -> object

Invoked with: <OpenImageIO.OpenImageIO.ImageInput object at 0x7fde68d9bcb0>, None

Environment Information

===============================================================================
*                                                                             *
*   Interpreter :                                                             *
*       python : 3.12.2 | packaged by conda-forge | (main, Feb 16 2024,       *
*   20:50:58) [GCC 12.3.0]                                                    *
*                                                                             *
*   colour-science.org :                                                      *
*       colour : 0.4.4                                                        *
*                                                                             *
*   Runtime :                                                                 *
*       imageio : 2.34.0                                                      *
*       matplotlib : 3.8.3                                                    *
*       numpy : 1.26.4                                                        *
*       scipy : 1.12.0                                                        *
*       tqdm : 4.66.2                                                         *
*       trimesh : 4.2.0                                                       *
*       OpenImageIO : 2.5.9.0                                                 *
*       xxhash : 3.4.1                                                        *
*                                                                             *
===============================================================================

defaultdict(dict,
            {'Interpreter': {'python': '3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 20:50:58) [GCC 12.3.0]'},
             'colour-science.org': {'colour': '0.4.4'},
             'Runtime': {'imageio': '2.34.0',
              'matplotlib': '3.8.3',
              'numpy': '1.26.4',
              'scipy': '1.12.0',
              'tqdm': '4.66.2',
              'trimesh': '4.2.0',
              'OpenImageIO': '2.5.9.0',
              'xxhash': '3.4.1'}})
@n-garc n-garc added the Defect label Mar 17, 2024
@KelSolaar
Copy link
Member

Hi @n-garc,

This one is odd because our tests pass with OIIO on Github with whatever latest is available. I tried with 2.5.6.0 and it is all good too whilst being much more recent than 2.1.19.0. I tried both EXR and JPG files.

Cheers,

Thomas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants