Skip to content

Commit

Permalink
Link pretty image from FITS file
Browse files Browse the repository at this point in the history
  • Loading branch information
wtgee authored Jul 29, 2018
1 parent b0a1222 commit b689fc1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
23 changes: 21 additions & 2 deletions pocs/utils/images/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,28 @@ def make_pretty_image(fname, timeout=15, **kwargs): # pragma: no cover
warn("File doesn't exist, can't make pretty: {}".format(fname))

if fname.endswith('.cr2'):
return _make_pretty_from_cr2(fname, timeout=timeout, **kwargs)
pretty_path = _make_pretty_from_cr2(fname, timeout=timeout, **kwargs)
elif fname.endswith('.fits'):
return _make_pretty_from_fits(fname, **kwargs)
pretty_path = _make_pretty_from_fits(fname, **kwargs)
else:
warn("File must be a Canon CR2 or FITS file.")
return None

# Symlink latest.jpg to the image; first remove the symlink if it already exists.
if os.path.exists(pretty_path) and pretty_path.endswith('.jpg'):
latest_path = '{}/images/latest.jpg'.format(os.getenv('PANDIR'))
try:
os.remove(latest_path)
except FileNotFoundError:
pass
try:
os.symlink(pretty_path, latest_path)
except Exception as e:
warn("Can't link latest image: {}".format(e))

return pretty_path
else:
return None


def _make_pretty_from_fits(
Expand Down
3 changes: 1 addition & 2 deletions scripts/cr2_to_jpg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ FNAME=$1
NAME=$2

JPG=${FNAME/cr2/jpg}
LATEST=${PANDIR}/images/latest.jpg

# Use exiftool to extract preview if it exists
if hash exiftool 2>/dev/null; then
Expand All @@ -21,4 +20,4 @@ fi

# Make thumbnail from jpg.
convert ${JPG} -thumbnail 1280x1024 -background black -fill red \
-font ubuntu -pointsize 24 label:"${NAME}" -gravity South -append ${LATEST}
-font ubuntu -pointsize 24 label:"${NAME}" -gravity South -append ${JPG}

0 comments on commit b689fc1

Please sign in to comment.