Created
August 23, 2022 14:13
-
-
Save ilfey/7bf8bbf514cfa1db22cbc39243fa848f to your computer and use it in GitHub Desktop.
HEIC to PNG converter
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
| import os | |
| from PIL import Image | |
| import pillow_heif | |
| os.chdir(input('Enter the full path to the folder with heic-images: ')) | |
| for path in os.listdir(): | |
| extension = path.split('.') | |
| if extension[-1].lower() == 'heic': | |
| image = pillow_heif.read_heif(path) | |
| Img = Image.frombytes( | |
| image.mode, | |
| image.size, | |
| image.data, | |
| "raw", | |
| ) | |
| del extension[-1] | |
| Img.save(" ".join(extension) + '.png') | |
| print(f'{extension}.heic converted to {extension}.png') | |
| print('All files are converted') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment