Why the following mentions so little Exif tags, compared to `exiftool` returning 167 entries?
```python from PIL import Image
img = Image.open('CENSORED.jpg') img_exif = img.getexif() for k, v in img_exif.items(): print("Tag", k, "Value", v) ``` ``` Tag 34853 Value 955 Tag 296 Value 2 Tag 34665 Value 226 Tag 271 Value Google Tag 272 Value Pixel 10 Pro XL Tag 305 Value HDR+ 1.0.888945374zd Tag 274 Value 1 Tag 306 Value 2026:07:04 12:19:24 Tag 531 Value 1 Tag 282 Value 72.0 Tag 283 Value 72.0 ```
Sep 8, 11:21am
The discrepancy between the number of EXIF tags returned by your Python script using Pillow (PIL) and the 167 entries returned by exiftool is due to how these tools handle EXIF metadata differently. Here’s why:
1. Pillow (PIL) Limitations
Pillow’s getexif() method only extracts a subset of EXIF tags, specifically those defined in the EXIF standard (e.g., IFD0, ExifIFD, GPSInfo, etc.).
It does not automatically parse or expose non-standard, proprietary, or extended EXIF tags (e.g., maker notes, custom tags from manufacturers like Google, Canon, or Nikon).
Pillow also does not recursively parse nested IFDs (e.g., MakerNote or UserComment) by default. These often contain additional metadata.
The tags you see (e.g., 34853, 296, 271, etc.) are standard EXIF tags like ExposureTime, Orientation, Make, Model, etc.
2. ExifTool’s Comprehensive Parsing
exiftool is a dedicated metadata extraction tool that:
Parses all known EXIF, IPTC, XMP, and other metadata formats (including proprietary maker notes).
Recursively extracts nested metadata (e.g., MakerNote from Google Pixel, which may contain dozens of additional tags).
Supports custom tag definitions and can interpret manufacturer-specific data (e.g., Google’s HDR+ settings, lens profiles, etc.).
MakerNote (Tag 37500): This tag often contains manufacturer-specific data (e.g., Google Pixel’s HDR+ settings, lens info, etc.). Pillow does not parse this by default, while exiftool does.
XMP/IPTC: Pillow does not extract these formats at all.
GPS Info: While Pillow can extract GPS tags, it may not format them as readably as exiftool.
4. How to Get More Tags in Python
If you want to extract all EXIF tags (including nested/proprietary ones) in Python, use:
exifread: Parses more tags than Pillow, including MakerNote.
piexif: Allows low-level access to EXIF data, including nested IFDs.
Subprocess call to exiftool:
python
import subprocess
result = subprocess.run(["exiftool", "CENSORED.jpg"], capture_output=True, text=True)
print(result.stdout)
5. Why Your Output is Limited
Your script only prints 12 tags because:
Pillow’s getexif() only returns standard EXIF tags it recognizes.
The MakerNote (and other nested tags) are not parsed by default.
No XMP/IPTC or other metadata formats are included.
Key Takeaway
Use exiftool (CLI) or piexif/exifread (Python) for comprehensive metadata extraction. Pillow is great for basic image manipulation but not for deep metadata analysis.
Sep 8, 11:21am
This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.