Isotr0py / pillow-jpegxl-plugin

Pillow plugin for JPEG-XL, using Rust for bindings.
GNU General Public License v3.0
21 stars 6 forks source link

Read/write EXIF data support #20

Closed chameroy closed 7 months ago

chameroy commented 9 months ago

Hello,

I've been experimenting with lossless JXL as a source format for image processing using PIL and OpenCV. Unfortunately, the output files (also in lossless JXL) lack the EXIF data found in the source files and I need to transfer that data. I've been successful in using PIL to transfer EXIF data from TIF to JPG, but I haven't been able to do the same with JXL. I've tried JXL -> JXL and TIF -> JXL, with no luck. It also appears that PIL (using the plugin) is unable to extract EXIF data from lossless JXL files.

Would it be possibly to get this functionality (assuming it doesn't already exist and I'm doing something wrong)? I've also tried ExifTool as a workaround, but no luck there either. Maybe it's a limitation of the format?

Thanks!

Isotr0py commented 9 months ago

It seems that jpeg reconstruction can store EXIF data with container:

with Image.open("IMG_20170723_133043.jpg") as img:
    img.save("IMG_20170723_133043-plugin.jxl", lossless=True)

And EXIF data:

& '.\exiftool(-k).exe' .\IMG_20170723_133043-plugin.jxl

ExifTool Version Number         : 12.76
File Name                       : IMG_20170723_133043-plugin.jxl
Directory                       : .
File Size                       : 694 kB
File Modification Date/Time     : 2024:02:12 11:13:09+08:00
File Access Date/Time           : 2024:02:12 11:13:34+08:00
File Creation Date/Time         : 2024:02:12 11:13:08+08:00
File Permissions                : -rw-rw-rw-
File Type                       : JXL
File Type Extension             : jxl
MIME Type                       : image/jxl
Major Brand                     : JPEG XL Image (.JXL)
Minor Version                   : 0.0.0
Compatible Brands               : jxl
Image Width                     : 4608
Image Height                    : 2592
Exif Byte Order                 : Big-endian (Motorola, MM)
...
Color Space                     : sRGB
Exif Image Width                : 4608
Exif Image Height               : 2592
Interoperability Index          : R98 - DCF basic file (sRGB)
Interoperability Version        : 0100
Sensing Method                  : One-chip color area
Scene Type                      : Directly photographed
Exposure Mode                   : Auto
White Balance                   : Auto
...

And it seems that encoding from pixels (PNG, TIF or other formats) won't keep EXIF data, because libjxl's API disable it by default: libjxl encoder API

Isotr0py commented 8 months ago

The new v1.2.0 release has supported EXIF data encoding.

Please have a try! :)