Skip to content

Commit

Permalink
Merge pull request #740 from zemogle/main
Browse files Browse the repository at this point in the history
Thumbnails fail if your FITS file isn't square
  • Loading branch information
jchate6 committed Nov 17, 2023
2 parents 8836b17 + 0068b2a commit a8f0a87
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tom_dataproducts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,9 @@ def get_preview(self, size=THUMBNAIL_DEFAULT_SIZE, redraw=False):
"""
if self.thumbnail:
im = Image.open(self.thumbnail)
if im.size != THUMBNAIL_DEFAULT_SIZE:
if im.size != THUMBNAIL_DEFAULT_SIZE and im.size[0] not in THUMBNAIL_DEFAULT_SIZE:
redraw = True
logger.critical("Redrawing thumbnail for {0} due to size mismatch".format(im.size))

if not self.thumbnail or redraw:
width, height = THUMBNAIL_DEFAULT_SIZE
Expand All @@ -262,6 +263,9 @@ def create_thumbnail(self, width=None, height=None):
:returns: Thumbnail file if created, None otherwise
:rtype: file
"""
if not self.data:
logger.error(f'Unable to create thumbnail for {self}: No data file found.')
return
if is_fits_image_file(self.data.file):
tmpfile = tempfile.NamedTemporaryFile(suffix='.jpg')
try:
Expand Down

0 comments on commit a8f0a87

Please sign in to comment.