Getting IFD1 exif information

Follow-up to #6641

A test image could be the following:
https://www.sun.ac.za/english/test-site/EXIF/sa.jpg

Please find below a code sample that uses the piexif library to extract all available exif information.

I wasn't able to retrieve the same information using only Pillow. In particular, not having the offsets to IFD1 and the embedded thumbnail makes it impossible (for me) to retrieve the tags from IFD1 as well as the raw data for the embedded thumbnail.

from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS
import piexif

def lookup_tag(tag, ifd):
    lu = GPSTAGS if ifd == 'GPS' else TAGS
    try:
        return f'0x{tag:04x}: {lu[tag]}'
    except:
        return f'0x{tag:04x}: ???'

def print_dict(data):
    for ifd, val in data.items():
        print(f'{ifd}:')
        if ifd == 'thumbnail':
            print(f'    {len(val)} bytes')
        else:
            for tag in val:
                print(f'    {lookup_tag(tag, ifd)}: {val[tag]}')

path = 'sa.jpg'

with Image.open(path) as i:
    d = piexif.load(i.info['exif'])
    print_dict(d)