Skip to content

Instantly share code, notes, and snippets.

@etherealxx
Created April 6, 2023 13:51
Show Gist options
  • Save etherealxx/a95c479e0607540b093ca8e39f0f89bf to your computer and use it in GitHub Desktop.
Save etherealxx/a95c479e0607540b093ca8e39f0f89bf to your computer and use it in GitHub Desktop.
Convert HEIC images to JPG in linux
#sudo apt-get install libheif-examples
import os, subprocess, shlex
dapath = "/home/ethereal/Downloads/Documents"
for file in os.listdir(dapath):
if file.endswith(".HEIC"):
heicpath = os.path.join(dapath, file)
heicname = file.partition(".")[0]
jpgpath = os.path.join(dapath, heicname + ".jpg")
command = f"heif-convert -q 100 {heicpath} {jpgpath}"
splitcommand = shlex.split(command)
subprocess.run(splitcommand)
for file in os.listdir(dapath):
if file.endswith("hdrgainmap.jpg"):
jpghdrpath = os.path.join(dapath, file)
os.remove(jpghdrpath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment