document some things

This commit is contained in:
Andrew Cassidy 2021-04-09 23:21:53 -07:00
parent 76da50d003
commit 1f0a577d7f

View File

@ -1,17 +1,19 @@
from PIL import Image
from typing import List
import pathlib
import click
def get_decoded_extensions(feature: str = 'open') -> List[str]:
"""Gets a list of extensions for Pillow formats supporting a supplied feature"""
extensions = Image.registered_extensions() # using registered_extensions() triggers lazy loading of format data
formats = getattr(Image, feature.upper()).keys()
return [ext for ext, fmt in extensions.items() if fmt in formats]
# noinspection PyUnusedLocal
def validate_decoded_extension(ctx, param, value):
"""Check if an extension for a decoded image is valid"""
if value[0] != '.':
value = '.' + value