uwDavid / convert-heic

Convert HEIC using Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Convert HEIC-to-jpeg using Python

A Python code that can be used anywhere to convert HEIC files to any other format supported by Pillow.

import os, sys
from pillow_heif import register_heif_opener
from pathlib import Path
from PIL import Image

register_heif_opener()

directory = "C:\\Path\\to\\directory"

files = [os.listdir(directory)][0]

for filename in files:
    image = Image.open(os.path.join(directory, filename))
    image.convert('RGB').save(os.path.join(directory, os.path.splitext(filename)[0] + '.jpg'))

References

Safan's Blog - It's a good starting point, but we couldn't use Image.open()

To open HEIC files using Pillow, there is a wonderful plug-in: pillow_heif

About

Convert HEIC using Python

License:MIT License


Languages

Language:PowerShell 91.1%Language:Batchfile 4.8%Language:Python 4.1%