Python HEIC to PNG#
Background#
I am a Windows User, while my Apple Friend send me images, sometimes those images are in HEIC format.
Hence I decided to make a Code to convert it to PNG so I can view those images.
Link to the Repo: Python HEIC to PNG
How it works#
The Code:#
from PIL import Image
from pillow_heif import register_heif_opener
import os
register_heif_opener()
heic_files = [photo for photo in os.listdir(r"input") if '.HEIC' or '.heic' in photo]
os.chdir(r"input")
for photo in heic_files:
print("Converting: ",photo)
temp_img = Image.open(photo)
png_photo = photo.replace('.HEIC','.png')
temp_img.save(png_photo)
print("Done")
How it works#
- Create a venv
- Install the required packages from requirements.txt
- Create a input file and add your HEIC images into it
- Run the script