first commit

This commit is contained in:
2025-04-18 12:57:34 +02:00
commit 5ccb5a3801
24 changed files with 33629 additions and 0 deletions

28
heif2jpg.py Normal file
View File

@@ -0,0 +1,28 @@
from PIL import Image
import pillow_heif
import os
# Automatically register HEIF format with Pillow
pillow_heif.register_heif_opener()
def convert_heif_to_jpg(input_folder, output_folder):
os.makedirs(output_folder, exist_ok=True)
for filename in os.listdir(input_folder):
if filename.lower().endswith(('.heif', '.heic')):
input_path = os.path.join(input_folder, filename)
output_path = os.path.join(output_folder, os.path.splitext(filename)[0] + '.jpg')
try:
with Image.open(input_path) as img:
rgb_img = img.convert("RGB")
rgb_img.save(output_path, "JPEG")
print(f"Converted: {filename} -> {output_path}")
except Exception as e:
print(f"Failed to convert {filename}: {e}")
# Example usage:
convert_heif_to_jpg("D:/3D/Majka/heic", "D:/3D/Majka/jpg")
# convert_heif_to_jpg(r"D:\3D\Majka\heic", r"D:\3D\Majka\jpg") shpuld also work
# convert_heif_to_jpg("D:\\3D\\Majka\\heic", "D:\\3D\\Majka\\jpg") should also work