Skip to content

Loss of Exif IFD attributes when saving new JPEG image #8634

@jmgzt

Description

@jmgzt

What did you do?

create a new jpeg image with IFD0 and ExifIFD tags

What did you expect to happen?

retreive all tags

What actually happened?

i retreive only the IFD0 tags

What are your OS, Python and Pillow versions?

  • OS: windows 10
  • Python: 3.12.1
  • Pillow: 11.0.0

--------------------------------------------------------------------
Pillow 11.0.0
Python 3.12.1 (tags/v3.12.1:2305ca5, Dec  7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)]
--------------------------------------------------------------------
Python executable is C:\Python\python.exe
System Python files loaded from C:\Python
--------------------------------------------------------------------
Python Pillow modules loaded from C:\Python\Lib\site-packages\PIL
Binary Pillow modules loaded from C:\Python\Lib\site-packages\PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 11.0.0
--- TKINTER support ok, loaded 8.6
--- FREETYPE2 support ok, loaded 2.13.3
--- LITTLECMS2 support ok, loaded 2.16
--- WEBP support ok, loaded 1.4.0
--- JPEG support ok, compiled for libjpeg-turbo 3.0.4
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.2
--- ZLIB (PNG/ZIP) support ok, loaded 1.3.1
--- LIBTIFF support ok, loaded 4.6.0
*** RAQM (Bidirectional Text) support not installed
*** LIBIMAGEQUANT (Quantization method) support not installed
*** XCB (X protocol) support not installed
--------------------------------------------------------------------
from PIL import Image, ExifTags


if __name__ == '__main__':

    newim = Image.new('RGB', [400,500])
    exif = newim.getexif()
# IFD0    
    exif[0x010E] = 'my description' # ImageDescription
    exif[0x013B] = "the artist" # Artist
    exif[0x0132] = "2020:02:02 00:00:00" # DateTime 
# ExifIFD  
    exif.get_ifd(ExifTags.IFD.Exif)[0x9003] = "2020:02:02 00:00:01" # DateTimeOriginal
    exif.get_ifd(ExifTags.IFD.Exif)[0x9004] = "2020:02:02 00:00:02" # DateTimeDigitized 

    newim.save('newimage.jpeg', exif=exif)
    newim.close()

    im = Image.open('newimage.jpeg')
    exf = im.getexif()
    print('IFD0', exf) # IFD0 {306: '2020:02:02 00:00:00', 315: 'the artist', 270: 'my description'}
    print('ExifIFD', exf.get_ifd(ExifTags.IFD.Exif)) # ExifIFD {} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions