-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtiffstats2.py
More file actions
30 lines (26 loc) · 1.1 KB
/
tiffstats2.py
File metadata and controls
30 lines (26 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from PIL import Image, TiffImagePlugin
import tifffile
def print_pil_metadata(filepath):
print("== PIL Metadata ==")
with Image.open(filepath) as img:
print(f"Format: {img.format}")
print(f"Size: {img.size}")
print(f"Mode: {img.mode}")
# Print TIFF tags
if hasattr(img, "tag_v2"):
for tag, value in img.tag_v2.items():
print(f"Tag {tag}: {value}")
else:
print("No tag_v2 metadata found.")
def print_tifffile_metadata(filepath):
print("\n== tifffile Metadata ==")
with tifffile.TiffFile(filepath) as tif:
for page_index, page in enumerate(tif.pages):
print(f"\n-- Page {page_index} --")
for tag in page.tags.values():
name, value = tag.name, tag.value
print(f"{name}: {value}")
if __name__ == "__main__":
filepath = "/home/umer/projects/vector_studio/icons/cropmapping-server-two/mapdata/Punjab2024First/stitched_tile_T43RDM.tiff" # 🔁 Replace with your TIFF file path
print_pil_metadata(filepath)
print_tifffile_metadata(filepath)