Giter Site home page Giter Site logo

janfri / mini_exiftool Goto Github PK

View Code? Open in Web Editor NEW
214.0 7.0 50.0 2.15 MB

This library is a wrapper for the Exiftool command-line application (https://exiftool.org) written by Phil Harvey. It provides the full power of Exiftool to Ruby: reading and writing of EXIF-data, IPTC-data and XMP-data. Branch master is for actual development and branch compatibility-version is for compatibility with Ruby 1.8 and exiftool versions prior 7.65.

License: GNU Lesser General Public License v2.1

Ruby 100.00%

mini_exiftool's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mini_exiftool's Issues

Changing the EXIF metadata is not working for the same file

I just updated some of the props of the image but it does not seem to work.

         inf = MiniExiftool.new(file.path)
        ap @a = inf.Make

        if inf.make
          print "-------- MAKE \n"
          inf.make = 'X'
          inf.Make = 'NA'
        end


        inf.save

        print "--0-=-=-=-=-=-=-=-= after \n"
        ap @b = inf

I don't see Make as X or NA.

Extract Group Data

Is there any way to extract the Exif Group data? I've looked through the code and can't see anywhere that the -G0 or -G1 options are used.

If this is not available then is this the best forum to raise a feature request?

Add support to get tags from network files using -fast option

ExifTool supports a very awesome option to load Exif data from slow network connections without the need to download a big photo file. I'd like to implement support for this option in MiniExifTool.

This is the CLI to use the -fast option:

wget -qO - http://farm6.staticflickr.com/5015/5458914734_8fd3f33278_o.jpg | exiftool -fast -

My idea if to create an initializer that receives the URL to the file and pipes it to exiftool -fast and then uses the already existing parse_output.

I've a few implementation questions:

  1. wget is not available in every SO. Any ideas on how to do the "download pipe" using pure Ruby classes? Any other command that is more widely available?
  2. I don't know the code base. Any tips on how to implement this?

What do you think?

Handle binary metadata tags, especially ICC_Profile

Perhaps this is out of the scope of mini_exiftool, but it would be great if mini_exiftool could support reading/writing of binary values.

More specifically, I am trying to assign an icc profile from one image to another. While I can read the icc profile subtags from the initial image using mini_exiftool (such as "ProfileCMMType", "ProfileVersion", "ProfileClass", "ProfileConnectionSpace", "ProfileDateTime", "ProfileFileSignature", "ProfileCreator", "ProfileID", "ProfileCopyright", "ProfileDescription"), these tags are non-writable. On the other hand, the ICC_Profile tag is writable, but I am not able to assign it the binary version of the ICC_Profile from the other image.

Thanks

#create_date applies local time zone to UTC timestamps

exiftool provides timestamps with time zone data:

$ curl -O https://private.ryanlue.com/2021-03-26_223527.dng
$ exiftool 2021-03-26_223527.dng | grep Date
File Modification Date/Time     : 2021:05:04 10:36:20-07:00 # PDT
File Access Date/Time           : 2021:05:04 10:36:08-07:00 # PDT
File Inode Change Date/Time     : 2021:05:04 10:36:20-07:00 # PDT
Modify Date                     : 2021:03:26 22:35:27       # UTC
Date/Time Original              : 2021:03:26 22:35:27       # UTC
Create Date                     : 2021:03:26 22:35:27       # UTC

mini_exiftool takes UTC timestamps and erroneously applies the local time zone to them:

$ ruby -rmini_exiftool -e "puts MiniExiftool.new('2021-03-26_223527.dng').create_date"
2021-03-26 22:35:27 -0700 # should be UTC, but is PDT

This behavior appears to occur with all filetypes (tested with .jpg, .dng, and .mov files)

Allow passing an IO to MiniExiftool.new

This should be pretty simple to implement (just pipe the IO into exiftool -). Support for the -fast option (see #15) could be a possible improvement, but isn't necessary.

Issue installing gem

I get this on windows:

Invalid argument - C:/Ruby192/lib/ruby/gems/1.9.1/gems/mini_exiftool-1.3.0/test/data/test 36"Bench.jpg (Errno::EINVAL)

Because of the weird quotes in the filename in test folder

Specify IPTC charset.

I have some files with german special characters (äöü) in IPTC fields but with no encoding information in Iptc:CodedCharacterset. I know that the encoding must be MacRoman because with exiftool file.jpg -charset iptc=MacRoman I get the characters just fine. I checked the code for a way to specify the charset but had no luck. Maybe I missed something?

Filenames containing $ fail to load.

Filenames with a dollar sign in them will fail to load, and throw an error when running MiniExiftool.new on them, due to being interpreted incorrectly by the shell.

The particular filename in this case is mar_300x250_$100kG_finfree_12.jpg for testing sake.

Problem with special characters in the filename (only Windows)

A '+' sign in the filename is converted by Shellwords.escape to '+'. That's not running on Windows. No idea how to correct this. Shellwords seems for unix and not for windows.

If a filename contains Umlaute 'ä', 'ö', ... a cmd.encode!('ISO-8859-1') is required on Windows.

Active storage

Hi !

Is it possible to user mini_exiftool with a blob active storage ?

I tried to download the blob and put it in public folder but didn't figure it out the path to put it in MiniExiftool.new.

Tried open, but get an error message NoMethodError (private method open' called for MiniExiftool:Class):`

Don't understand how it works !!

Thx

remove all exif tags

Exiftool comand have a 'all' option to remove all tags. It is posible with your wrapper?

Reading/writing XMP data

I wonder how to read or write XMP data...

The command to read would be

exiftool -xmp -b test.pdf

As the description of MiniExiftool mentions XMP data, I wonder how to do this.

The first call .to_hash is very slow

On two separate machines with different a OS on each (OSX and Ubuntu);

Calling twenty_mini = MiniExiftool.new '27.jpg' is quick
Calling twenty_mini.to_hash is very slow. 2-3 seconds.

During testing, I found that it's only the first call to to_hash. Calling to_hash on separate image files is quick as expected.

Define respond_to_missing?

Hi, thanks for your work!

I tried to use Forwardable to wrap calls to MiniExiftool instance for my project, but I got warning regarding forwarding to private methods.
Seems like it should be solved by defining respond_to_missing?. https://bugs.ruby-lang.org/issues/13326
IMO defining the respond_to_missing? method is generally a good idea.

suggestion: implement batch reading

exiftool is much faster if you can read a batch of files at once, largely because of the overhead of firing up Perl along with exiftool's own environment for each file individually. exiftool itself supports this; in fact, you can just give a directory as its "file":

exiftool -DateTimeOriginal /path/to/directory/

I would like to suggest that mini_exiftool should support this. I have not thought about the syntax. :)

This feature is sometimes called "multi get". Note that Mceachen's exiftool wrapper gem permits this: https://github.com/mceachen/exiftool

Weird error with unicode characters in path "Wildcards don't work in the directory specification"

This may not be a bug in mini_exiftool, but right now, i don't really know what to make of it. If you could help me pin it down, that would be amazing.

I'm on windows, and i have path names that contain unicode characters. One path looks like this:

C:\tmp\2015-03-23 Test with german umlaut äöü\IMG_1000.JPG

Now if i fire up an irb, i can open that file with ruby, but not with mini_magick

f = File.open("C:/tmp/2015-03-23 Test with german umlaut äöü/IMG_1000.JPG")
# => #<File:C:/tmp/2015-03-23 Test with german umlaut äöü/IMG_1000.jpeg>
f.size
# => 18713

# so far, so good! Let's try mini_exiftool, now.

require 'mini_exiftool'
# => true
m = MiniExiftool.new("C:/tmp/2015-03-23 Test with german umlaut äöü/IMG_1000.JPG")
# MiniExiftool::Error: Wildcards don't work in the directory specification
# No matching files

#        from C:/Tools/Ruby21/lib/ruby/gems/2.1.0/gems/mini_exiftool-2.5.0/lib/mini_exiftool.rb:137:in `load'
#        from C:/Tools/Ruby21/lib/ruby/gems/2.1.0/gems/mini_exiftool-2.5.0/lib/mini_exiftool.rb:101:in `initialize'
#        from (irb):11:in `new'
#        from (irb):11
#        from C:/Tools/Ruby21/bin/irb:11:in `<main>'

note that this is not a "file not found", because i can easily provoke that:

m = MiniExiftool.new("C:/tmp/2015-03-23 Test with german umlaut äöü/IMG_1337.JPG")
# MiniExiftool::Error: File 'C:/tmp/2015-03-23 Test with german umlaut äöü/IMG_1337.JPG' does not exist.
#        from C:/Tools/Ruby21/lib/ruby/gems/2.1.0/gems/mini_exiftool-2.5.0/lib/mini_exiftool.rb:121:in `load'
#        ...

the same example works fine, if i change the directory name to omit the äöü part:

m = MiniExiftool.new("C:/tmp/2015-03-23 Test without german umlaut/IMG_1000.JPG")
# => #<MiniExiftool:0x3031f50 @opts={:numerical=>false, :composite=>true, ...

The error message (Wildcards don't work in the directory specification) does not come from anywhere within mini_exiftool, at least not that i can find it with github's code search.

Exiftool itself is also not at fault (at least not alone), because i can do this without a problem:

> exiftool.exe "C:\tmp\2015-03-23 Test with german umlaut äöü\IMG_1000.JPG"
ExifTool Version Number         : 9.90
File Name                       : IMG_1000.JPG
...

I'm really somewhat stuck.

PStore::Error: nested transaction

Version 2.4.2, also 2.4.1. Happens under Ruby 1.9.3. and Ruby 2.1.2.

Backtrace:

/usr/lib/ruby/2.1.0/pstore.rb:313 in "transaction"
/gems/mini_exiftool-2.4.2/lib/mini_exiftool.rb:459 in "pstore_get"
/gems/mini_exiftool-2.4.2/lib/mini_exiftool.rb:320 in "original_tag"
/gems/mini_exiftool-2.4.2/lib/mini_exiftool.rb:181 in "block in tags"
/gems/mini_exiftool-2.4.2/lib/mini_exiftool.rb:181 in "map"
/gems/mini_exiftool-2.4.2/lib/mini_exiftool.rb:181 in "tags"

The calling code looks like

metadata = MiniExiftool.new(path)
exif_tags = metadata.tags.dup 
exif_tags.compact.sort.each do |tag|
  ...
end

The exception comes from the metadata.tags call.

# Version 2.1, February 1999

The date had me concerned. I think it's wrong. Trivial.

Line 13 in the the main file.

Thanks for this great gem.

I got here because I'm having an issue, but's it's probably how I'm doing it.

Attach back the metadata to its original file

I extracted the metadata in xmp format from some jpeg and raw images now i need to attach that in some different file. How can i do that? I am able to do the same thing with ICC format with png images but its not working with jpeg images.

IPTC Data types, "seem" to work but don't get persisted.

MiniExifTool seems to validate proper IPTC data structure, and then accepts ONLY the properly formatted structure, but then never persists the validated structure. Here is an example where 'sample.jpg" can be ANY ".jpg" file.

photo = MiniExiftool.new 'sample.jpg'
photo["CopyrightOwner"] = "jason"
 => "jason"
photo.save
photo.errors
 => {"copyrightowner"=>"Warning: Improperly formed structure for XMP-plus:CopyrightOwner"}

So far, this is absolutely correct. As per the IPTC spec, CopyrightOwner requires 2 children nodes, "CopyrightOwnerID" && "CopyrightOwnerID".

So if we add those:

photo["CopyrightOwner"]='{"CopyrightOwnerID" : "23412412","CopyrightOwnerName" : "jason"}}'
photo.save
 => true

But the NEITHER the output file, nor the existing photo object have those values saved:

photo["CopyrightOwner"]
 => ""

NOR

exiftool sample.jpg | grep "Copyright Owner"
Copyright Owner        :     

Expected Result: "Copyright Owner" would be persisted in the EXIF data as per IPTC spec.

Missing data

Maybe I'm missing something but command line exiftool on a OM (Olympus) camera file results in about 540 items and a few of them:
➜ exiftool -a -u -g1 "/Users/gscar/Pictures/_Photo Processing Folders/Watched folder for import to Photos/2024.03.25-16.09.59.gs.O.orf" ---- ExifTool ---- ExifTool Version Number : 12.76 … Create Date : 2024:03:25 16:09:59 Offset Time : -07:00 … Drive Mode : Single Shot; Electronic shutter Panorama Mode : Off
Drive Mode is unavailable in mini_exiftool.
Can I access DriveMode?

US postal codes are parsed to integers instead of strings

US postal codes beginning with a 0 and containing another zero are converted to integers and drop the initial 0.

For example, a postal code like '02109' (Boston MA) will become 2109.

I believe that line 464 of mini_exiftool.rb (convert_after_load) is intended to preserve postal codes as strings, but the match condition (when /^0+[1-9]+$/) does not handle this example properly because the second zero causes the match to fail. I propose that the condition be changed to: when /^0+[0-9]+$/.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.