From 8f539d409707d4fed9ef96da2b779f2264e76210 Mon Sep 17 00:00:00 2001 From: CodeByMrFinchum Date: Thu, 23 Jan 2025 14:56:13 +0100 Subject: [PATCH] fix: Fixed missing lens and incorrect user comment bug. --- CHANGELOG.md | 4 ++++ src/optima35/image_handler.py | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdc8164..3b241c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog ## 0.12.x +### 0.12.2: Bug fixes +- Fixed missing lens in meta data +- Fixed incorrect User Comment, aka, Scanner name + ### 0.12.1 - Error in GitVersion.yml file resulted in jump from 6 to 12. diff --git a/src/optima35/image_handler.py b/src/optima35/image_handler.py index 10232c2..0bf8c1a 100644 --- a/src/optima35/image_handler.py +++ b/src/optima35/image_handler.py @@ -1,5 +1,6 @@ from PIL import Image, ImageDraw, ImageFont, ImageEnhance, ImageQt import piexif +import piexif.helper from fractions import Fraction class ImageProcessor: @@ -78,7 +79,7 @@ class ImageProcessor: save_params["quality"] = jpg_quality elif file_type == "png": save_params["compress_level"] = png_compressing - elif file_type not in ["webp", "jpg", "png"]: + elif file_type not in ["webp", "jpg", "png"]: input(f"Type: {file_type} is not supported. Press Enter to continue...") return # Add EXIF data if available @@ -117,7 +118,8 @@ class ExifHandler: piexif.ImageIFD.YResolution: (72, 1), } exif_ifd = { - piexif.ExifIFD.UserComment: user_data["user_comment"].encode("utf-8"), + piexif.ExifIFD.LensModel: user_data["lens"].encode("utf-8"), + piexif.ExifIFD.UserComment: piexif.helper.UserComment.dump(user_data["user_comment"]), piexif.ExifIFD.ISOSpeedRatings: int(user_data["iso"].encode("utf-8")), piexif.ExifIFD.PixelXDimension: imagesize[0], piexif.ExifIFD.PixelYDimension: imagesize[1],