7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/pano/image.rb', line 7
def read_info file_path
json = `exiftool -d "%Y-%m-%d %H:%M:%S %z" -j "#{file_path}" 2>&1`
return {:error => "File not found"} if json =~ /^File not found/i
data = JSON.parse(json)[0]
data[:width] = data["ImageWidth"]
data[:height] = data["ImageHeight"]
data[:size] = data["ImageSize"]
data[:file_size] = data["FileSize"]
data[:camera_model] = data["Model"]
data[:keywords] = data["Keywords"] || ""
data[:owner_name] = data["OwnerName"] data[:iptc_digest] = data["IPTCDigest"] data[:created_at] = try_parse_date data, "CreateDate"
data[:modified_at] = try_parse_date data, "ModifyDate"
data[:file_modified_at] = try_parse_date data, "FileModifyDate"
data[:orientation] = data[:width] > data[:height] ? 'h' : 'v'
data[:fov] = data["FOV"].to_f
if data["PhotoshopQuality"].present?
quality = data["PhotoshopQuality"]
data[:quality] = quality <= 9 ? quality * 10 : quality
end
data
end
|