Get Exif Data into jpeg without recompression (or exif to original jpg)

Hello
Darktable is a great help for organizing old images from our town.
There are old images that i don’t want to re-compress on export.
And there is the new exif metadata description and title … i gave
the images in darktable.
How do i get this metadata into the jpg image without re-compressing it?
Is this possible on export with the copy function? (i couldn’t figure this out)
Is it possible to write the metadata into the original jpg without re-compressing it?
(its the strategy of darktable to not change the original by default)

Welcome to the forum!

If you want to guarantee the image itself is not altered, using something like exiftool might be the best way. With it, you can transfer and/or add metadata, and it’ll copy over the binary blobs without modification. It’s a command line program, but there are GUI shells available for it.

https://exiftool.org/
https://exiftool.org/exiftool_pod.html#WRITING-EXAMPLES

2 Likes

Hi Friedbert,
hopefully Glenn’s advice works for you because my understanding is if a JPG is opened in any software and then a single pixel changed then when the image is saved or exported it will be recompressed. I am not sure if just opening an image in DT, doing no edit but changing the metadata will cause a compression of the image. Someone else might be able to shed light on that one.

I don’t want to say it’s like that in all raw image processing software, but I can’t see how it’s not. An image processing program can’t work the image in JPEG’s compressed format, so it imports it into an internal uncompressed array that is not JPEG, PNG, or anything else. When the worked image is saved, in the case of JPEG it’s re-compressed.

That is my understanding and why JPGs are not the best for editing.

Plus, as dt is a non-destructive editor, it never touches the “source” image file whatever its format, you can just export to another JPEG (which means re-compression). Exiftool or exiv2 is indeed the way to go.

1 Like

Yup, the only exception to this are the very limited corner cases (lossless crop and rotate, with the limitation of only supporting images that are exact multiples of the JPEG block size) handled by jpegtran.

As others have said, copying metadata using a tool explicitly designed for the purposes (exiftool or exiv2 being the most well known examples) is the way to go.

Hello
Many thanks for all those hints and helpings.

As i got those old jpg files and i don’'t want to alter the image (compressesd pixelimagepart) but integrate metadata into the image i thought i could use the “export → file format → copy” option and only alter the metadata in the jpg header. Like exif tool does.
Perhaps there is a lua script that is able to copy the sidecar files metadata to a given jpg … in conjunction with exif tools…

DT is completly able to take care of my database and the metadata. I don’t want to switch back and forth to an other tool.

Hello,

I have a lua script that might help you, which however would need some adaptation as the purpose is slightly different.

Today, I am using dt for tagging, rating and raw processing, then export to jpg into my ‘overall’ database together with images from mobile sources managed by digikam. I prefer having all metadata in the jpg file itself. However, before dt became very handy for tagging, I have tagged only the jpg file in digiKam after exporting them.

As a result, I have one raw database and one jpg database - and thats where the lua script comes in. It checks for all raw files in a directory if there are corresponding jgs (in an other folder) and loads tags, ratings and some color flags into the raw files in dt. It also can go the other way round to update the metadata of the jpg files in case I have modified them in dt - thats probably the part that you would be interested in. However, if you have jpg in dt, you will need to change some search pattern in the script. For sure you have to adapt the search folders. If there is some interest, maybe someone could give me some advice how to share that script.

As I am writing this, just another idea for your problem. Why you don’t export all your images with the new metadata to another folder. Then you can just use exiftools to copy all metadata from the new image to the corresponding old original. Once you are done, you could delete the new files.
For safety, better create a backup of your original first :grin:

Best regards,
Klaus