Closed fcy closed 8 years ago
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.
Interesting idea. Didn't know the -fast option until now. ;-)
At the moment I don't see a simple solution that is universally applicable.
@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
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: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 existingparse_output
.I've a few implementation questions:
What do you think?