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

Trouble using freeimage plugin on MacOS arm64 #1053

Open
aknoerig opened this issue Nov 22, 2023 · 2 comments
Open

Trouble using freeimage plugin on MacOS arm64 #1053

aknoerig opened this issue Nov 22, 2023 · 2 comments

Comments

@aknoerig
Copy link

I just ran into a number of strange issues with the freeimage plugin and am wondering if it's just me. :)

Side note: Initially, I had trouble using imageio.plugins.freeimage.download() causing SSL certificate errors, so I used the command line alternative imageio_download_bin freeimage.

Running something as simple as:

import imageio
img = iio.imread('imageio:chelsea.png', format='PNG-FI')

results in the error: OSError: PNG-FI can not handle the given uri.

From the traceback, it seems to be related to how LegacyPlugin handles the Request

self = <imageio.core.legacy_plugin_wrapper.LegacyPlugin object at 0x106069390>
request = <imageio.core.request.Request object at 0x106068af0>
legacy_plugin = <Format PNG-FI - Portable Network Graphics>
...
        if not self._format.can_read(request):
>         raise InitializationError(f"`{self._format.name}`" f" can not read `{source}`.")
E     imageio.core.request.InitializationError: `PNG-FI` can not read `imageio:chelsea.png`

I tested on a Ubuntu system, too, and there it's working as expected.

My setup:

  • imageio v2.33.0
  • installed via conda environment
  • MacOS 14.1.1
  • MacBook with M2 chip (arm64)
@aknoerig aknoerig changed the title Trouble using PNG-FI on MacOS Trouble using PNG-FI on MacOS arm64 Nov 22, 2023
@aknoerig
Copy link
Author

Upon further digging, it does seem to be caused by the fact that the freeimage library can't be loaded properly.

Unfortunately, there is no error logged that indicates this:

  • _format.can_read returns False if the freeimage library can't be loaded, but it just prints the above error message
  • iio.plugins.freeimage.download() doesn't throw any errors, just returns None
  • imageio.plugins._freeimage.get_freeimage_lib() doesn't throw any errors, just returns the path the library was downloaded too
  • imageio.plugins._freeimage.fi.load_freeimage() finally returns a message that the library can't be loaded

If this is validated by other users, I'd suggest to include an appropriate error message for the above functions.

@aknoerig
Copy link
Author

Ah, I just discovered the related discussions in #628, which has more about how to fix the arm64 support.

Leaving this here to suggest an update to the documentation and possibly an enhanced error message.

@aknoerig aknoerig changed the title Trouble using PNG-FI on MacOS arm64 Trouble using freeimage plugin on MacOS arm64 Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant