Skip to content

Instantly share code, notes, and snippets.

@ilfey
Created August 23, 2022 14:13
Show Gist options
  • Select an option

  • Save ilfey/7bf8bbf514cfa1db22cbc39243fa848f to your computer and use it in GitHub Desktop.

Select an option

Save ilfey/7bf8bbf514cfa1db22cbc39243fa848f to your computer and use it in GitHub Desktop.
HEIC to PNG converter
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