-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Added FITS reading, deprecate FitsStubImagePlugin #6056
Conversation
if _handler is None or not hasattr("_handler", "save"): | ||
raise OSError("FITS save handler not installed") | ||
_handler.save(im, fp, filename) | ||
offset = math.ceil(self.fp.tell() / 2880) * 2880 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation mentioned that the offset for the image data was a multiple of 2880.
https://fits.gsfc.nasa.gov/fits_primer.html
Each header or data unit is a multiple of 2880 bytes long. If necessary, the header or data unit is padded out to the required length with ASCII blanks or NULLs depending on the type of unit.
The data unit, if present, immediately follows the last 2880-byte block in the header unit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also add to release notes.
Do we need to worry about the removed FITSStubImageFile
class?
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Ok, I've figured out how to deprecate FitsStubImagePlugin.
Since this PR is only adding support for reading, you might wonder what someone is supposed to do if they were saving images using FitsStubImagePlugin. Well, it turns out, that's not actually a concern - there is a bug (#6071) that means they can't have been saving images using FitsStubImagePlugin. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, couple of little docs autolink nits.
The links to FitsImagePlugin are now there - but I discovered I couldn't link to FitsStubImagePlugin, because I removed it from the documentation to prevent new users from finding it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, let's just code format it then.
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Resolves #4054, adding reading of FITS files by upgrading the FITS plugin from a StubImageFile to an ImageFile.
I have updated the hopper FITS test image. The original was similar, but not equal, to
hopper("L")
, so I generated this new file with Pillow and ImageMagick. The updated file is still L mode, like the original.