Keeping EXIF data from raw to jpeg in Python, anybody have a good system?

I’m converting raw files to 16-bit tiffs and then after tone-mapping to jpegs. I keep running into issues where the exif data gets too big to save to a jpeg (there’s a 65k limit, who knew?), so I try to keep only the bare essentials (I don’t even know what ExifOffset is and yet it takes up like 65k all by itself sometimes), but then I run into the problem where even though I’m saving with an embedded ICC profile, there is apparently not enough metadata for image viewers to properly decode them and they look garish (in Gwenview and geeqie, but not showFoto which apart from interface problems seems to do color management very well).

Sorry for the long sentence, but if anybody has a process they have perfected, don’t keep it to yourself!

the offset is the memory address where the EXIF data starts. It’s value does not mean how much EXIF data there is.

Please post a “garish” JPEG with an embedded ICC profile and I’ll gladly take a look at. I’m able to extract a profile, note it’s size and open it for viewing it’s tags and curves and stuff.

Please note that there is more metadata in an image than just EXIF and not all Viewers are created equal. If you post the raw file for your JPEG, that would help.

I don’t use Python.

1 Like

Must this be done in Python? Is exiv2 not an option? From the man page:

   in | insert

Insert metadata from corresponding *.exv, XMP sidecar (*.xmp) and thumbnail files. Use option -S .suf to change the suffix of the input files. Since files of any supported format can be used as input files, this command can be used to copy the metadata between files of different formats. Modification commands can be applied on-the-fly.

   $ exiv2 -l/tmp -S.CRW insert /data/*.JPG

Copy all metadata from CRW files in the /tmp directory to JPG files with corresponding basenames in the /data directory. Note that this copies metadata as is, without any modifications to adapt it to the requirements of the target format. Some tags copied like this may not make sense in the target image.

My thought exactly. Wouldn’t it be simpler to use exiv2 or ExifTool to extract and embed the data?