-
I'm no pro Python user, but early this year Dec 2023/Jan 2024, I was able to save TIFF files with TIFF tags via JPEG compression. Then my code stopped working some months after. Today I finally got it working and now I see why. In Release 10.2.0, one of the update notes says:
So when my code broke I was constantly getting this error:
My Question Is: Here's the relevant portion of my code: # Load Original Image to get MetaData
imgOriginal = TiffImageFile(filePath)
imgOriginal.load()
metaData = imgOriginal.tag_v2
imgOriginal.close()
# Save original image as compressed version
imgReopen = Image.open(filePath).convert('RGBA')
background = Image.new('RGBA', imgReopen.size, (255,255,255))
imgToBeCompressed = Image.alpha_composite(background, imgReopen)
imgReopen.close()
imgToBeCompressed.save(filePath, compression='jpeg')
# Open & Save Metadata to newly compressed image
imgNeedsMetaData = TiffImageFile(filePath)
imgNeedsMetaData.load()
imgNeedsMetaData.save(filePath, tiffinfo=metaData) My current solution has been just to revert back to release 10.1.0 Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes, this change came from #7654 after a user requested the ability to set the value in #6607 The simple solution would be to add # Open & Save Metadata to newly compressed image
imgNeedsMetaData = TiffImageFile(filePath)
imgNeedsMetaData.load()
del metaData[278]
imgNeedsMetaData.save(filePath, tiffinfo=metaData) This is the number of the RowsPerStrip tag. Pillow/src/PIL/TiffImagePlugin.py Line 92 in 8d0a6d0 |
Beta Was this translation helpful? Give feedback.
Yes, this change came from #7654 after a user requested the ability to set the value in #6607
The simple solution would be to add
del metaData[278]
to your code.This is the number of the RowsPerStrip tag.
Pillow/src/PIL/TiffImagePlugin.py
Line 92 in 8d0a6d0