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

Closed
fcy opened this Issue Nov 7, 2013 · 3 comments

2 participants

@fcy
fcy commented Nov 7, 2013

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?

@fcy
fcy commented Nov 7, 2013

In case, there's no good way to replace wget or you think it should get in the project because it would increase complexity. I just found the following way of achieving the goal:

json_str = `wget -qO - http://farm6.staticflickr.com/5015/5458914734_8fd3f33278_o.jpg | exiftool -fast2 -`
exif = MiniExiftool.from_json(json_str)
exif.datetimeoriginal
# => 2011-02-15 08:27:51 -0200

It works for me. But I'd be interested in a discussion what other ways it could be done.

@janfri
Owner

Interesting idea. Didn't know the -fast option until now. ;-)

At the moment I don't see a simple solution that is universally applicable.

@janfri janfri added the idea label Mar 14, 2014
@janfri
Owner

@fcy MiniExiftool now supports es well as IO instances as the options fast and fast2. Checkout version 2.7.0.

Use Ruby standard lib

require 'mini_exiftool'
require 'net/http'
require 'open3'

uri = URI('http://farm6.staticflickr.com/5015/5458914734_8fd3f33278_o.jpg')
output, input = IO.pipe

# Reading asynchron
Thread.new do
  Net::HTTP.start(uri.host, uri.port) do |http|
    request = Net::HTTP::Get.new uri
    http.request request do |response|
      response.read_body do |chunk|
        input.write chunk
      end
    end
  end
  io.close
end

exif = MiniExiftool.new output, fast2: true
puts exif.datetimeoriginal

Use curl

require 'mini_exiftool'
require 'open3'

input, output = Open3.popen3('curl -s http://farm6.staticflickr.com/5015/5458914734_8fd3f33278_o.jpg')
input.close

exif = MiniExiftool.new output, fast2: true
puts exif.datetimeoriginal
@janfri janfri closed this Apr 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment