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

Reading FITS images #4054

Closed
burhankhanlodhy opened this issue Sep 9, 2019 · 3 comments · Fixed by #6056
Closed

Reading FITS images #4054

burhankhanlodhy opened this issue Sep 9, 2019 · 3 comments · Fixed by #6056
Projects

Comments

@burhankhanlodhy
Copy link

Whenever I try to run PIL.FitsStubImagePlugin.register_handler()
it gives me an error saying PIL doesn't have any FitsStubImagePlugin module.
How do I open my fits file as it says I need a handler to operate .fits file

@radarhere radarhere changed the title Fit Stub Image Plugin FitsStubImagePlugin Sep 9, 2019
@radarhere
Copy link
Member

radarhere commented Sep 9, 2019

You will see in the docs that FITS is listed as an identify-only format - meaning that read and write functionality is not yet supported in Pillow. If you have code for reading or writing FITS files, and would like to connect your code to Pillow, then you can register a handler -

from PIL import Image
from PIL import FitsStubImagePlugin

class FitsHandler:
    def open(self, im):
        ...

    def load(self, im):
        ...
        return image

    def save(self, im, fp, filename):
        ...

fits_handler = FitsHandler()
FitsStubImagePlugin.register_handler(fits_handler)

im = Image.open("sample.fits")

@radarhere
Copy link
Member

I've created #5405 to help in a small way, reading the image headers to determine the mode and size of the image.

@radarhere radarhere changed the title FitsStubImagePlugin Reading FITS images Apr 14, 2021
@radarhere
Copy link
Member

I've created PR #6056 to resolve this. If that is merged, you should no longer have to worry about register_handler(), but can instead just Image.open("sample.fits").

@mergify mergify bot closed this as completed in #6056 Feb 20, 2022
Pillow automation moved this from New Issues to Closed Feb 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Pillow
  
Closed
Development

Successfully merging a pull request may close this issue.

2 participants