You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
Find below adjusted code if you want to parse recursively a folder. The initial HEIC will be renamed in *.heic.old
You than can easily revert to initial status by removing *.heic.jpg and rename *.heic.old in *.heic
enjoy
#HEIC to JPG image format batch conversion script for Python 3. Tested on Windows 10.
#You will need to have ImageMagick installed: https://www.imagemagick.org/
import os, subprocess
#Convert recursively (parsing all sub directorites) all HEIC files into JPG from the rootdir below
#then script would rename initial files to *.heic.old
rootdir = "\\xxx.xxx.x.xx\Public\Shared Pictures\Photo"
def heicToJpg(rootdir):
for it in os.scandir(rootdir):
if it.is_dir():
print('parsing %s...' % it.path)
for filename in os.listdir(it.path):
if filename.lower().endswith(".heic"):
print('Converting to jpg %s...' % os.path.join(it, filename))
subprocess.run(["magick", "%s" % os.path.join(it, filename), "%s" % os.path.join(it, (filename[0:-5] + '.heic.jpg'))])
# os.remove("%s" % os.path.join(it, filename))
os.rename(os.path.join(it, filename), os.path.join(it, filename[0:-5] + '.heic.old'))
heicToJpg(it)
else: #we are on a file
filename = it.path
if filename.lower().endswith(".heic"):
print('Converting to JPG %s...' % os.path.join(it, filename))
subprocess.run(["magick", "%s" % os.path.join(it, filename), "%s" % os.path.join(it, (filename[0:-5] + '.heic.jpg'))])
# os.remove("%s" % os.path.join(it, filename))
os.rename(os.path.join(it, filename), os.path.join(it, filename[0:-5] + '.heic.old'))
heicToJpg(rootdir)
The text was updated successfully, but these errors were encountered:
Hi,
Find below adjusted code if you want to parse recursively a folder. The initial HEIC will be renamed in *.heic.old
You than can easily revert to initial status by removing *.heic.jpg and rename *.heic.old in *.heic
enjoy
#HEIC to JPG image format batch conversion script for Python 3. Tested on Windows 10.
#You will need to have ImageMagick installed: https://www.imagemagick.org/
import os, subprocess
#Convert recursively (parsing all sub directorites) all HEIC files into JPG from the rootdir below
#then script would rename initial files to *.heic.old
rootdir = "\\xxx.xxx.x.xx\Public\Shared Pictures\Photo"
def heicToJpg(rootdir):
for it in os.scandir(rootdir):
if it.is_dir():
print('parsing %s...' % it.path)
for filename in os.listdir(it.path):
if filename.lower().endswith(".heic"):
print('Converting to jpg %s...' % os.path.join(it, filename))
subprocess.run(["magick", "%s" % os.path.join(it, filename), "%s" % os.path.join(it, (filename[0:-5] + '.heic.jpg'))])
# os.remove("%s" % os.path.join(it, filename))
os.rename(os.path.join(it, filename), os.path.join(it, filename[0:-5] + '.heic.old'))
heicToJpg(it)
else: #we are on a file
filename = it.path
if filename.lower().endswith(".heic"):
print('Converting to JPG %s...' % os.path.join(it, filename))
subprocess.run(["magick", "%s" % os.path.join(it, filename), "%s" % os.path.join(it, (filename[0:-5] + '.heic.jpg'))])
# os.remove("%s" % os.path.join(it, filename))
os.rename(os.path.join(it, filename), os.path.join(it, filename[0:-5] + '.heic.old'))
heicToJpg(rootdir)
The text was updated successfully, but these errors were encountered: