Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExiftoolNotInstalled error when trying to remove EXIF data #28

Open
kiskoza opened this issue Oct 24, 2022 · 1 comment
Open

ExiftoolNotInstalled error when trying to remove EXIF data #28

kiskoza opened this issue Oct 24, 2022 · 1 comment

Comments

@kiskoza
Copy link

kiskoza commented Oct 24, 2022

Hi. I'm trying to remove some sensitive information (e.g.: GPS location) from uploaded files using exiftool.

When I try to check the existing EXIF data, it works:

Exiftool.new(file_path, '-ignoreMinorErrors').to_hash
# {
#   "source_file": "image_with_gps.jpg",
#   "exif_tool_version": 11.88,
#   "file_name": "image_with_gps.jpg",
#   "file_size": "6.0 MB",
#   ...
# }

However, as soon as I try to change something in the file it starts complaining that exiftool is not installed

Exiftool.new(file_path, '-ignoreMinorErrors -gps:all= "-gps*=" -tagsfromfile @ -Orientation')
# Exiftool::ExiftoolNotInstalled raised

The problem seems to be with the lines checking that the result of the exiftool command is an empty string: lib/exiftool.rb#L58-L60.

  1. Is this gem meant to be used for manipulating EXIF data? If no, is there one that you can recommend?
  2. Is there any additional exiftool option I need to add to keep my command compatible with this gem?

I would help creating a PR to make my use-case viable if you're interested in it

@morozgrafix
Copy link
Member

morozgrafix commented Nov 15, 2022

Thank you for opening an issue. I believe that both exiftool.rb and exiftool_vendored.rb were intended as utilities to read exif data from files and not manipulate the files. I'm able to reproduce the issue that you've described. I will dig a little bit more into it in the next week. Meanwhile one of the workarounds would be to call built in Ruby Kernel methods with a -q flag for example (of course depending on the desired output you want to return).

Something along those lines with verbose output:

irb(main):008:0> %x{ exiftool path/to/test.jpg -gps:all= "-gps*=" -tagsfromfile @ -Orientation }
=> "    1 image files updated\n"

or with a -q quiet flag and a system call

irb(main):009:0> system('exiftool path/to/test.jpg -gps:all= "-gps*=" -tagsfromfile @ -Orientation -q')
=> true

And of course improvement PRs are always welcome.

taitus added a commit to rockandror/consuldemocracy that referenced this issue May 11, 2023
In order to remove metadata from PDF documents we will use the
exiftool_vendored gem.

The following line:
  Exiftool.new(attachment_path, "-overwrite_original -all:all=")
Overwrites the original file with another file without metadata.

So far this is the best solution we have found to perform this
metadata deletion.

When using Exiftool an exception is thrown, so we added a rescue
to handle it. Here is a task created where this problem is
discussed: exiftool-rb/exiftool.rb#28.
We'll wait to see if this will be fixed in future versions.

Translated with www.DeepL.com/Translator (free version)
taitus added a commit to rockandror/consuldemocracy that referenced this issue May 11, 2023
In order to remove metadata from PDF documents we will use the
exiftool_vendored gem.

The following line:
  Exiftool.new(attachment_path, "-overwrite_original -all:all=")
Overwrites the original file with another file without metadata.

So far this is the best solution we have found to perform this
metadata deletion.

When using Exiftool an exception is thrown, so we added a rescue
to handle it. Here is a task created where this problem is
discussed: exiftool-rb/exiftool.rb#28.
We'll wait to see if this will be fixed in future versions.

Translated with www.DeepL.com/Translator (free version)
taitus added a commit to rockandror/consuldemocracy that referenced this issue May 22, 2023
In order to remove metadata from PDF documents we will use the
exiftool_vendored gem.

The following line:
  Exiftool.new(attachment_path, "-overwrite_original -all:all=")
Overwrites the original file with another file without metadata.

So far this is the best solution we have found to perform this
metadata deletion.

When using Exiftool an exception is thrown, so we added a rescue
to handle it. Here is a task created where this problem is
discussed: exiftool-rb/exiftool.rb#28.
We'll wait to see if this will be fixed in future versions.

Translated with www.DeepL.com/Translator (free version)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants