Merge branch 'fix/bugs' into 'main'

fix: Fixed missing lens and incorrect user comment bug.

See merge request CodeByMrFinchum/optima35!20
This commit is contained in:
Mr Finchum 2025-01-23 13:56:37 +00:00
commit 303596e20c
2 changed files with 8 additions and 2 deletions

View file

@ -1,6 +1,10 @@
# Changelog # Changelog
## 0.12.x ## 0.12.x
### 0.12.2: Bug fixes
- Fixed missing lens in meta data
- Fixed incorrect User Comment, aka, Scanner name
### 0.12.1 ### 0.12.1
- Error in GitVersion.yml file resulted in jump from 6 to 12. - Error in GitVersion.yml file resulted in jump from 6 to 12.

View file

@ -1,5 +1,6 @@
from PIL import Image, ImageDraw, ImageFont, ImageEnhance, ImageQt from PIL import Image, ImageDraw, ImageFont, ImageEnhance, ImageQt
import piexif import piexif
import piexif.helper
from fractions import Fraction from fractions import Fraction
class ImageProcessor: class ImageProcessor:
@ -78,7 +79,7 @@ class ImageProcessor:
save_params["quality"] = jpg_quality save_params["quality"] = jpg_quality
elif file_type == "png": elif file_type == "png":
save_params["compress_level"] = png_compressing 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...") input(f"Type: {file_type} is not supported. Press Enter to continue...")
return return
# Add EXIF data if available # Add EXIF data if available
@ -117,7 +118,8 @@ class ExifHandler:
piexif.ImageIFD.YResolution: (72, 1), piexif.ImageIFD.YResolution: (72, 1),
} }
exif_ifd = { 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.ISOSpeedRatings: int(user_data["iso"].encode("utf-8")),
piexif.ExifIFD.PixelXDimension: imagesize[0], piexif.ExifIFD.PixelXDimension: imagesize[0],
piexif.ExifIFD.PixelYDimension: imagesize[1], piexif.ExifIFD.PixelYDimension: imagesize[1],