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

TypeError when using Pillow Image object #65

Closed
DavidMonk00 opened this issue Mar 21, 2021 · 5 comments
Closed

TypeError when using Pillow Image object #65

DavidMonk00 opened this issue Mar 21, 2021 · 5 comments

Comments

@DavidMonk00
Copy link

I have just started using this library and was able to have success when registering two numpy arrays, however when I instead use the code in the README for Image objects, I get the following error:

TypeError: 'JpegImageFile' object is not subscriptable

Is this an error you can recreate? Perhaps a library incompatibility?

Versions:
Python: 3.9.2
PIL: 8.1.2
astroalign: 2.3.1

Full error stack:

TypeError                                 Traceback (most recent call last)
~/.local/lib/python3.9/site-packages/astroalign.py in find_transform(source, target, max_control_points, detection_sigma, min_area)
    258     try:
--> 259         if len(_data(source)[0]) == 2:
    260             # Assume it's a list of (x, y) pairs

TypeError: 'JpegImageFile' object is not subscriptable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-56-6234a8d4138f> in <module>
      3 source = Image.open("capture_200s_iso800_1.jpg")
      4 target = Image.open("capture_200s_iso800_2.jpg")
----> 5 registered, footprint = aa.register(source, target)
      6 # Convert back to pillow image if necessary:
      7 registered = Image.fromarray(registered.astype("unit8"))

~/.local/lib/python3.9/site-packages/astroalign.py in register(source, target, fill_value, propagate_mask, max_control_points, detection_sigma, min_area)
    461 
    462     """
--> 463     t, __ = find_transform(
    464         source=source,
    465         target=target,

~/.local/lib/python3.9/site-packages/astroalign.py in find_transform(source, target, max_control_points, detection_sigma, min_area)
    268             )[:max_control_points]
    269     except Exception:
--> 270         raise TypeError("Input type for source not supported.")
    271 
    272     try:

TypeError: Input type for source not supported.
@martinberoiz
Copy link
Member

Hello David,

Thanks for the report! I indeed can reproduce the error. It's a bit embarrassing since I didn't test this case of opening from an image in my unit tests. I am working on a new minor release that will come very soon.

@DavidMonk00
Copy link
Author

DavidMonk00 commented Mar 22, 2021

I'm glad I can help, looking forward to using the new version when it's released!

@martinberoiz
Copy link
Member

Hey David, I just released version 2.3.2 with the bug fix. Sorry for the inconvenience, let me know if this fixes it for you.

@DavidMonk00
Copy link
Author

Hi Martin, I can confirm that with the new version I am no longer seeing the error, thank you very much for your quick work in fixing it!

@martinberoiz
Copy link
Member

Awesome, glad to hear that.

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

2 participants