Reputation: 65
I have TIFFs that do not have the Photometric tag set. I want to do something like this in PIL
from PIL import Image
im = Image.open("image.tiff")
im.tag[262] = 1
im.save("out_image.tiff", tiffinfo=im.tag)
But since the 262 tag is not set, the image isn't valid and won't open in PIL to set it.
I have tried using LibTIFF
tiffset -s 262 1 image.tiff
It sets the photometric tag, but doesn't retain the GPS tags in my images.
Is there a way to add the 262 tag without losing the other metadata associated with the image?
Edit:
The error message:
Traceback (most recent call last): File "<pyshell#23>", line 1, in im = Image.open('D:/image.tiff') File "C:\Users\Ben\AppData\Local\ESRI\conda\envs\Image_dev\lib\site-packages\PIL\Image.py", line 2896, in open "cannot identify image file %r" % (filename if filename else fp) PIL.UnidentifiedImageError: cannot identify image file 'D:/image.tiff'
Upvotes: 0
Views: 141