Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FitsStubImagePlugin.py 1.6KB

1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #
  2. # The Python Imaging Library
  3. # $Id$
  4. #
  5. # FITS stub adapter
  6. #
  7. # Copyright (c) 1998-2003 by Fredrik Lundh
  8. #
  9. # See the README file for information on usage and redistribution.
  10. #
  11. from . import FitsImagePlugin, Image, ImageFile
  12. from ._deprecate import deprecate
  13. _handler = None
  14. def register_handler(handler):
  15. """
  16. Install application-specific FITS image handler.
  17. :param handler: Handler object.
  18. """
  19. global _handler
  20. _handler = handler
  21. deprecate(
  22. "FitsStubImagePlugin",
  23. 10,
  24. action="FITS images can now be read without "
  25. "a handler through FitsImagePlugin instead",
  26. )
  27. # Override FitsImagePlugin with this handler
  28. # for backwards compatibility
  29. try:
  30. Image.ID.remove(FITSStubImageFile.format)
  31. except ValueError:
  32. pass
  33. Image.register_open(
  34. FITSStubImageFile.format, FITSStubImageFile, FitsImagePlugin._accept
  35. )
  36. class FITSStubImageFile(ImageFile.StubImageFile):
  37. format = FitsImagePlugin.FitsImageFile.format
  38. format_description = FitsImagePlugin.FitsImageFile.format_description
  39. def _open(self):
  40. offset = self.fp.tell()
  41. im = FitsImagePlugin.FitsImageFile(self.fp)
  42. self._size = im.size
  43. self.mode = im.mode
  44. self.tile = []
  45. self.fp.seek(offset)
  46. loader = self._load()
  47. if loader:
  48. loader.open(self)
  49. def _load(self):
  50. return _handler
  51. def _save(im, fp, filename):
  52. msg = "FITS save handler not installed"
  53. raise OSError(msg)
  54. # --------------------------------------------------------------------
  55. # Registry
  56. Image.register_save(FITSStubImageFile.format, _save)