Skip to content

Commit

Permalink
fix: uploading new image format function
Browse files Browse the repository at this point in the history
  • Loading branch information
LisaHopcroft committed Oct 10, 2022
1 parent 8d5c8eb commit 997cb95
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/image_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@


ImageFormat = collections.namedtuple("ImageFormat", ["extension", "formatter"])
DEFAULT_IMAGE_FORMAT = "png"


def pick_image_format():
try:
fmt = os.environ["IMAGE_FORMAT"]
except KeyError:
raise Exception("You must set the IMAGE_FORMAT environment variable to svg or png")
fmt = os.environ.get("IMAGE_FORMAT", DEFAULT_IMAGE_FORMAT)

if fmt == "svg":
return ImageFormat("svg", SVG)
if fmt == "png":
return ImageFormat("png", Image)
raise ValueError(f"Unknown IMAGE_FORMAT '{fmt}', you must specify one of 'svg' or 'png'")

0 comments on commit 997cb95

Please sign in to comment.