Keep image metadata (EXIF, IPTC Copyright ...)

Hello everybody,
I’m looking for your way to keep the EXIF, IPTC (copyright) ​​metadata of an image.
After the resize or crop of an image, the metadata gets lost. I hope someone can help me please.

Best regards

Which driver are you using, gd or ImageMagick?

The imageMagic driver uses the -strip option, as far as I remember that’s the one that removes the exif data, but don’t have the time to verify that now.

Maybe there is an option to set this to false somewhere, if not this could then be solved with a custom IM driver that doesn’t use the strip option.

Guess the same applies to the GD driver.

1 Like

Hello Sonja, thank you.

The driver is ImageMagick. I read in another topic that i have to delete the -strip option in the thumbs.php, but that does not help to keep the metadata. Hmmm, not so easy to handle this.

Maybe you can check and create a thumb on the command line to see if the exif data is preserved

1 Like

I use this command to recursively optimise images on the command line. Pretty sure it is the -strip flag that does it, not sure why it doesnt work for you. Try this on the images in terminal… (you need imagemagick installed obviously, which you can easily do via Homebrew)

1 Like

I tested this in a Starterkit:


//  $command[] = '-strip';

in /kirby/vendor/getkirby/toolkit/lib/thumb.php

And the exif data is preserved. Just make sure to remove old thumbs from the thumb folder first, otherwise they won’t get recreated.

Also, instead of fiddling with the source code, this change should be made in a custom driver.

Hello Sonja, thank you so much.

I don’t know why, but for me this dosen’t work.

Here are the steps i do:

  • New installation with the Kirby starterkid
  • Uncommented the “$command[] = ‘-strip’” line.
  • Deleted all the folders in the “thumbs” folder.
  • Doing this in my template “<?= $image->crop(590, 400, 90)->url() ?>”
  • Uploaded an image with EXIF and IPTC Informations in the panel.

After the resize of the image all the EXIF and IPTC informations are gone.

Here is the original Image (in the panel files folder, with EXIF and IPTC infos):

This is the image after the resize (without the EXIF and IPTC infos):

Tricky :wink:

I can suggest an alternative solution here. Use a hook to extract and store the meta data from the image into the files meta data. You can do this easily with a hook. That way, if it does get stripped from the image, you still have the information.

1 Like

@alexander-hacke Have you tested the convert command on the command line?

I wonder why we get different results. Since the thumbs are obviously generated, the ImageMagick driver seems to be working. Hm,:thinking:.

Oh yeah it’s strange.

Sorry, i don’t understand the convert command on the command line :grimacing:
Maybe i try it again in the next week with a fresh brain.