diff --git a/lib/image_formats.py b/lib/image_formats.py index c004ce0..047000b 100644 --- a/lib/image_formats.py +++ b/lib/image_formats.py @@ -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'")