Skip to content

Commit

Permalink
Small wrap up of fixes and improvements
Browse files Browse the repository at this point in the history
- Fixed an issue with editing objects in the Pick plugin
- Fixed an issue where image metadata not always loaded correctly with
  Pillow for RGB images
- Added support for Apple HEIF (.HEIC) RGB images if pillow-heif is installed
  • Loading branch information
ejeschke committed Jan 29, 2025
1 parent 27c1f8d commit ff5c558
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
7 changes: 7 additions & 0 deletions doc/WhatsNew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
What's New
++++++++++

Ver 5.3.0 (unreleased)
======================
- Fixed an issue with editing objects in the Pick plugin
- Fixed an issue where image metadata not always loaded correctly with
Pillow for RGB images
- Added support for Apple HEIF (.HEIC) RGB images if pillow-heif is installed

Ver 5.2.0 (2024-10-21)
======================
- Substituted puremagic package for python-magic (works better across
Expand Down
2 changes: 1 addition & 1 deletion ginga/canvas/CanvasObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, **kwdargs):
if not hasattr(self, 'kind'):
self.kind = None
# For debugging
self.name = None
self.name = kwdargs.get('name', None)
self.viewer = None

# For callbacks
Expand Down
4 changes: 2 additions & 2 deletions ginga/rv/plugins/Pick.py
Original file line number Diff line number Diff line change
Expand Up @@ -1701,9 +1701,9 @@ def create_pick_box(self, obj):

obj.color = self.pickcolor
args = [obj,
self.dc.Point(x, y, 10, color='red'),
self.dc.Point(x, y, 10, color='red', editable=False),
self.dc.Text(x1, y2, '{0}: calc'.format(self._textlabel),
color=self.pickcolor)
color=self.pickcolor, editable=False)
]

self.pick_obj = self.dc.CompoundObject(*args)
Expand Down
20 changes: 14 additions & 6 deletions ginga/util/io/io_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from ginga.misc import Bunch
from ginga import trcalc

# optional imports
try:
# do we have opencv available?
import cv2
Expand All @@ -32,6 +33,12 @@
except ImportError:
have_exif = False

try:
# for opening HEIC (Apple image) files)
from pillow_heif import register_heif_opener
register_heif_opener()
except ImportError:
pass
# For testing...
#have_exif = False
#have_opencv = False
Expand Down Expand Up @@ -442,7 +449,8 @@ class PillowFileHandler(BaseRGBFileHandler):
'image/bmp',
'image/x-tga',
'image/x-icns',
'image/vnd.microsoft.icon']
'image/vnd.microsoft.icon',
'image/heif']

@classmethod
def check_availability(cls):
Expand Down Expand Up @@ -559,15 +567,15 @@ def load_idx(self, idx, **kwargs):
return data_obj

def _get_header(self, image_pil, kwds):
if hasattr(image_pil, '_getexif'):
info = image_pil._getexif()
if hasattr(image_pil, 'getexif'):
info = image_pil.getexif()
if info is not None:
for tag, value in info.items():
kwd = TAGS.get(tag, tag)
kwds[kwd] = value

else:
self.logger.warning("can't get EXIF data; no _getexif() method")
self.logger.warning("can't get EXIF data; no getexif() method")

# is there an embedded color profile?
if 'icc_profile' in image_pil.info:
Expand All @@ -585,8 +593,8 @@ def _process_image(self, image_pil, metadata=None):
if kwds is None:
kwds = Header()
metadata['header'] = kwds
else:
kwds = Header()
else:
kwds = Header()

try:
self._get_header(image_pil, kwds)
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ recommended =
matplotlib>=3.8
opencv-python-headless>=4.5.4
exifread>=2.3.2
pillow-heif>=0.21.0
astroquery>=0.3.5
python-dateutil>=2.8.2
photutils
Expand Down

0 comments on commit ff5c558

Please sign in to comment.