Created
June 2, 2022 17:34
-
-
Save izikeros/83bce3d2a60c4a800c4fac4cfb2bb1c8 to your computer and use it in GitHub Desktop.
Code snippet with example for medium article
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_images_in_dir(directory: str, extensions: List[str]) -> list: | |
| """ | |
| Get list of images in a directory, recursively. Include extensions: | |
| .jpg, .png, cr2, etc. | |
| :param directory: str | |
| :param extensions: list | |
| :return: list | |
| """ | |
| images = [] | |
| for root, dirs, files in os.walk(directory): | |
| for file in files: | |
| if file.lower().endswith(tuple(extensions)): | |
| images.append(os.path.join(root, file)) | |
| return images |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment