It seems most people rather keep the exif data, and have trouble keeping it. I have the opposite problem - we have a profile picture upload and it keeps the exif data. I'd like to strip that off the images. Is there a way to actively do that?

  • 1
    From original picture? Or from image styles? As a rule, Drupal does not alter user-uploaded files in any way, it only creates altered copies if needed, so this is a big difference.
    – Mołot
    Sep 23, 2014 at 10:28
  • The altered copies though do not keep the exif data.
    – Wtower
    Sep 23, 2014 at 10:33
  • Yes, from the original picture. I'd like the user to keep the opportunity to upload an image. Then I'd like to strip the exif data, and then use that version. It doesn't matter to me if I have to create a copy for it to work. The amount of pictures uploaded is fairly small.
    – user857990
    Sep 23, 2014 at 10:39
  • @Wtower sometimes they do. It depends on the library that is doing alterations, and on the specific set of operations configured. It is a wide and interesting topic ;)
    – Mołot
    Sep 23, 2014 at 10:44

3 Answers 3


You can do this by implementing hook_file_presave($file)

This hook is called when a file has been added to the database. The hook doesn't distinguish between files created as a result of a copy or those created by an upload.

In this hook, you need to:

  1. Test if file is really an image. I suggest using mimetype for this task: $file->filemime
  2. Recognize which image processing library your Drupal is using. See image_get_available_toolkits(), image_gd_check_settings() and ImageMagick.
  3. Process that file. This part is general programming issue already well answered on Stack Overflow - I see no point in reposting it here, I think I covered Drupal part of the question now.

Now, it looks like the easiest way to do this is with File metadata manager (Drupal 8 and above). It has a submodule file_mdm_exif, which allows you to read and write EXIF information for JPEF and TIFF images.

You would still need to add some custom code to automatically remove EXIF data before saving.


To strip the metadata from image styles, you can use the Image Effects module. Install the module, go to the relevant image styles (/admin/config/media/image-styles/manage/), and then add the Strip metadata effect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.