Skip to content

Instantly share code, notes, and snippets.

@Alveel
Last active April 7, 2022 10:57
Show Gist options
  • Save Alveel/9c1b513d9a98bddf4a5b706e1e5a0223 to your computer and use it in GitHub Desktop.
Save Alveel/9c1b513d9a98bddf4a5b706e1e5a0223 to your computer and use it in GitHub Desktop.
Convert Apple HEIC to JPEG, without any changes
#!/usr/bin/env python3
# Convert HEIC images in the current working directory to JPEG
# Uses Python's Wand library, and Pathlib
# https://docs.wand-py.org/en/0.6.7/index.html
from pathlib import Path
from wand.image import Image
heic = Path('./').glob('*.heic')
for f in heic.__iter__():
with Image(filename=f) as original:
# https://docs.wand-py.org/en/0.6.7/guide/write.html
with original.convert('jpeg') as converted:
renamed = f.with_suffix('.jpeg')
print(renamed)
converted.save(filename=renamed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment