extexif 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +2 -0
- data/Manifest.txt +15 -0
- data/README.txt +52 -0
- data/Rakefile +21 -0
- data/ext/COPYING +504 -0
- data/ext/ChangeLog +18 -0
- data/ext/Makefile +149 -0
- data/ext/README +30 -0
- data/ext/exif.c +653 -0
- data/ext/exif.rd.en +146 -0
- data/ext/exif.rd.ja +154 -0
- data/ext/extconf.rb +15 -0
- data/lib/extexif.rb +135 -0
- data/test/test_extexif.rb +10 -0
- metadata +71 -0
data/ext/exif.rd.en
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
= ruby-libexif - an interface to libexif library
|
4
|
+
|
5
|
+
((<libexif|URL:http://libexif.sourceforge.net>)) is the library for parsing image information contained in EXIF format images. ruby-libexif provides a simple interface to this library.
|
6
|
+
|
7
|
+
= Usage
|
8
|
+
|
9
|
+
require 'exif'
|
10
|
+
|
11
|
+
#
|
12
|
+
# generate Exif object from 'image.jpg' in the current directory.
|
13
|
+
#
|
14
|
+
exif = Exif.new('image.jpg')
|
15
|
+
#
|
16
|
+
# generate an empty Exif object, and load the image data into it.
|
17
|
+
#
|
18
|
+
exif = Exif.new
|
19
|
+
File.open('image.jpg') { |f| exif << f.read }
|
20
|
+
|
21
|
+
|
22
|
+
#
|
23
|
+
# To access the value of the tag, use Exif#[].
|
24
|
+
# The return value are string object.
|
25
|
+
# You can specify a tag by its name or title, or ID.
|
26
|
+
# For example, if you want to know the manufacturer of
|
27
|
+
# the recording equipment that generated the image,
|
28
|
+
# you can get the information by specifying the tag as follows:
|
29
|
+
#
|
30
|
+
# * exif['Manufacturer'] ; "tag title"
|
31
|
+
# * exif['Make'] ; "tag name"
|
32
|
+
# * exif[0x010f] ; "tag ID"
|
33
|
+
#
|
34
|
+
(Please refer ((<Exif.[]>)) , ((<Exif#[]>)) for more details, and ((<Exif#list_tags>)) for available tags in the IFD.)
|
35
|
+
# get a value of the specifid tag by its title
|
36
|
+
p exif["Manufacturer"] # -> "FUJIFILM"
|
37
|
+
# get a value of the specified tag by its tag ID (string)
|
38
|
+
p exif[0xa001] # -> "FUJIFILM"
|
39
|
+
|
40
|
+
|
41
|
+
#
|
42
|
+
# If the image has thumbnail, you can extract it by
|
43
|
+
# Exif#extract_thumbnail, or Exif#thumbnail
|
44
|
+
#
|
45
|
+
|
46
|
+
# extract a thumbnail, and save it to a file.
|
47
|
+
File.open('thumb.jpg', 'wb') {|dest| exif.thumbnail(dest)}
|
48
|
+
# set a new thumbnail to Exif object. note that existing
|
49
|
+
# thumbnail, if exists, will be destroyed.
|
50
|
+
File.open('src.jpg', 'rb'){|src| exif.thumbnail = src.read }
|
51
|
+
|
52
|
+
= Reference
|
53
|
+
|
54
|
+
== class Exif
|
55
|
+
|
56
|
+
=== class methods
|
57
|
+
|
58
|
+
--- Exif.new
|
59
|
+
|
60
|
+
generate a new Exif object with empty data.
|
61
|
+
|
62
|
+
--- Exif.new(fpath)
|
63
|
+
|
64
|
+
load the image data from (({fpath})), and generates a new Exif object. If the image is not EXIF-formatted, exception ((<Exif::Error::NotExifFormat>)) raises.
|
65
|
+
|
66
|
+
--- Exif.[](tagid)
|
67
|
+
|
68
|
+
get a description of ((|tagid|)). the returned value is an array object:
|
69
|
+
|
70
|
+
['tag title', ['tag name', 'description of the tag', 'tag ID']]
|
71
|
+
|
72
|
+
=== instance methods
|
73
|
+
|
74
|
+
--- Exif#data=(str)
|
75
|
+
--- Exif#<<(str)
|
76
|
+
|
77
|
+
set the image data given as String object. The existing data in the object, if exists, will be destroyed.
|
78
|
+
|
79
|
+
--- Exif#list_tags(ifd)
|
80
|
+
|
81
|
+
return an array consists of tags defiend in IFD ((|ifd|)). each elements is following array object:
|
82
|
+
|
83
|
+
["tag title", "tag ID('0xdddd')"]
|
84
|
+
|
85
|
+
((|ifd|)) is one of the constants defined in ((<Exif::IFD>)).
|
86
|
+
|
87
|
+
--- Exif#byte_order
|
88
|
+
|
89
|
+
--- Exif#ifd
|
90
|
+
|
91
|
+
return a string that represents current IFD.
|
92
|
+
|
93
|
+
--- Exif#ifd=(ifd)
|
94
|
+
|
95
|
+
set IFD of the object to ((|ifd|)). ((|ifd|)) is one of the constants defined in ((<Exif::IFD>)), or either one of "0", "1", "GPS", "Interoperability". If invalid IFD is given, exception ((<Exif::Error::InvalidIFD>)) raises.
|
96
|
+
|
97
|
+
--- Exif#[](tag)
|
98
|
+
|
99
|
+
return the value (string) of the (({tag})). If the tag is not supported by current IFD, exception ((<Exif::Error::TagNotFound>)) raises. Unless you have set IFD by ((<Exif#ifd=>)), this method tries to find the tag and its value over available IFDs.
|
100
|
+
|
101
|
+
--- Exif#each_entry(use_tag_id=false) {|tag, val| ...}
|
102
|
+
|
103
|
+
executes the block, with the block arguments being tag title ((|tag|)) over the LFDs and its value ((|val|)). If ((|use_tag_id|)) is ((|true|)), ((|tag|)) is set to tag ID (denoted by '0xdddd').
|
104
|
+
|
105
|
+
--- Exif#extract_thumbnail(dest)
|
106
|
+
--- Exif#thumbnail(dest)
|
107
|
+
|
108
|
+
write the thumbnail of the image to ((|dest|)), using (({dest#<<})). If the image does not have thumbnail, exception ((<Exif::Error::ThumbnailNotFound>)) raises.
|
109
|
+
|
110
|
+
== modules
|
111
|
+
|
112
|
+
== Exif::IFD
|
113
|
+
|
114
|
+
IFDs defined in libexif.
|
115
|
+
|
116
|
+
--- Exif::IFD::Zero
|
117
|
+
--- Exif::IFD::One
|
118
|
+
--- Exif::IFD::EXIF
|
119
|
+
--- Exif::IFD::GPS
|
120
|
+
--- Exif::IFD::Interoperability
|
121
|
+
--- Exif::IFD::Any
|
122
|
+
This constant should be set in ((<Exif#ifd=>)) if ((<Exif#[]>)) searches tag over above five IFDs. Exif object is set to this value by default.
|
123
|
+
|
124
|
+
== Exif::ByteOrder
|
125
|
+
|
126
|
+
constants that represents byte order of the EXIF image.
|
127
|
+
|
128
|
+
--- Exif::ByteOrder::INTEL
|
129
|
+
--- Exif::ByteOrder::MOTOROLA
|
130
|
+
|
131
|
+
== Exception classes
|
132
|
+
|
133
|
+
RuntimeError --- Exif::Error -+- Exif::Error::NotExifFormat
|
134
|
+
|- Exif::Error::InvalidIFD
|
135
|
+
|- Exif::Error::ThumbnailNotFound
|
136
|
+
`- Exif::Error::TagNotFound
|
137
|
+
--- Exif::Error
|
138
|
+
|
139
|
+
Runtime errors occurred by using ruby-libexif belong to this class, or following derived classes.
|
140
|
+
|
141
|
+
--- Exif::Error::NotExifFormat
|
142
|
+
--- Exif::Error::InvalidIFD
|
143
|
+
--- Exif::Error::TagNotFound
|
144
|
+
--- Exif::Error::ThumbnailNotFound
|
145
|
+
|
146
|
+
=end
|
data/ext/exif.rd.ja
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
= ruby-libexif - libexif �� ruby ����Ȥ�����Υ饤�֥�ꡣ
|
4
|
+
|
5
|
+
libexif��EXIF�ե����ޥåȤΥ�������饿���������Ф��뤿���C�饤�֥��Ǥ����ܥ饤�֥���(({exif(1)}))��Ʊ���ε�ǽ��ruby�����ڤ˰������Ȥ���Ū�Ȥ��Ƥ��ޤ���
|
6
|
+
|
7
|
+
libexif, exif�ˤĤ��Ƥϡ�((<URL:http://libexif.sourceforge.net>))�Ȥ��Ʋ�������
|
8
|
+
|
9
|
+
= �Ȥ���
|
10
|
+
|
11
|
+
require 'exif'
|
12
|
+
|
13
|
+
# �����ȥǥ��쥯�ȥ��image.jpg����Exif���֥������Ȥ��������롣
|
14
|
+
exif = Exif.new('image.jpg')
|
15
|
+
# Exif���֥������Ȥ����������ǡ�����Ϳ���롣
|
16
|
+
exif = Exif.new
|
17
|
+
File.open('image.jpg') { |f| exif << f.read }
|
18
|
+
|
19
|
+
# �����Υ����ȥ���Ѥ����ͤ����롣
|
20
|
+
p exif["Manufacturer"] # -> "FUJIFILM"
|
21
|
+
# ������ID���Ѥ����ͤ����롣
|
22
|
+
p exif['0xa001'] # -> "FUJIFILM"
|
23
|
+
#
|
24
|
+
# ���ߤΤȤ������֤��ͤ�ʸ���֥������Ȥ����줵��Ƥ��ޤ���
|
25
|
+
# �ޤ��������Ȥ��ơ�����3�Ĥ�ɽ����Ϳ���뤳�Ȥ��Ǥ��ޤ���
|
26
|
+
# exif["Manufacturer"] ; �����Υ����ȥ�
|
27
|
+
# exif["Make"] ; ������EXIF-2.1�ǵ��ꤵ�줿̾��
|
28
|
+
# exif[0xa001] ; ������ID��16��ɽ������ʸ����
|
29
|
+
# IFD�ˤ�äƵ��ꤵ��Ƥ��륿���μ���ϰۤʤ�ޤ�����
|
30
|
+
# (({Exif#ifd=}))�ˤ�ä�����Ū��IFD����ꤷ�ʤ��¤ꡢ���Ƥ�IFD���оݤˤ���
|
31
|
+
# ������õ���Ф����б������ͤ��֤����Ȥ��ޤ�������Ū��IFD����ꤷ���塢
|
32
|
+
# ���Τ褦��ư����ᤷ�����Ȥ��ϡ�(({Exif#ifd=}))�ΰ�����
|
33
|
+
# (({Exif::IFD::Any}))(����Ū���Ѱդ����⥸�塼�����)����ꤷ�Ʋ�������
|
34
|
+
#
|
35
|
+
# �����ξܺ٤ˤĤ��Ƥϡ�(({Exif.[]}))���Ѥ���Ĵ�٤뤳�Ȥ��Ǥ��ޤ���
|
36
|
+
# �ޤ�������IFD�ˤ��������Ѳ�ǽ�ʥ����ˤĤ��Ƥ�(({Exif#list_tags}))��
|
37
|
+
# �Ѥ���Ĵ�٤뤳�Ȥ��Ǥ��ޤ���)
|
38
|
+
|
39
|
+
# ����ͥ������Ф����ե��������¸���롣
|
40
|
+
File.open('thumb.jpg', 'wb') {|dest| exif.thumbnail(dest)}
|
41
|
+
# ����ͥ�������ꤹ�롣����¸�ߤ��륵��ͥ�����˴�����롣
|
42
|
+
File.open('src.jpg', 'rb'){|src| exif.thumbnail = src.read }
|
43
|
+
|
44
|
+
= ��ե����
|
45
|
+
|
46
|
+
== class Exif
|
47
|
+
|
48
|
+
=== ���饹��å�
|
49
|
+
|
50
|
+
--- Exif.new
|
51
|
+
|
52
|
+
������ǡ���������Exif���֥������Ȥ��������ޤ���
|
53
|
+
|
54
|
+
--- Exif.new(fpath)
|
55
|
+
|
56
|
+
(({fpath}))�ǻ��ꤵ��륤������ɤߡ�Exif���֥������Ȥ��������ޤ����������EXIF�ե����ޥåȤǤϤʤ���硢�㳰((<Exif::Error::NotExifFormat>))��ȯ�����ޤ���
|
57
|
+
|
58
|
+
--- Exif.[](tagid)
|
59
|
+
|
60
|
+
ʸ�����ͤǻ��ꤵ���((|tagid|))�˴ؤ������������ޤ����֤��ͤ�
|
61
|
+
|
62
|
+
['�����Υ����ȥ�', ['������̾��', '����������', '����ID(����)']]
|
63
|
+
|
64
|
+
�Ǥ���
|
65
|
+
|
66
|
+
|
67
|
+
=== ��å�
|
68
|
+
|
69
|
+
--- Exif#load(fpath)
|
70
|
+
|
71
|
+
--- Exif#data=(str)
|
72
|
+
--- Exif#<<(str)
|
73
|
+
|
74
|
+
ruby��String���֥������Ȥ�Ϳ����줿�ǡ������˥��åȤ��ޤ������Ǥ˥ǡ��������åȤ���Ƥ������ˤϡ�������˴�����ޤ���
|
75
|
+
|
76
|
+
--- Exif#list_tags(ifd)
|
77
|
+
|
78
|
+
IFD ((|ifd|)) ���������Ƥ��륿���Υꥹ�Ȥ�������֤��ޤ��������Ǥ�
|
79
|
+
|
80
|
+
["�����Υ����ȥ�", "����ID('0xdddd')"]
|
81
|
+
|
82
|
+
�Ȥ�������Ǥ���((|ifd|))�ˤ�((<Exif::IFD>))�ʲ�����������������Ѥ��Ʋ�������
|
83
|
+
|
84
|
+
--- Exif#byte_order
|
85
|
+
|
86
|
+
������ΥХ��ȥ����������֤��ޤ����֤��ͤ�((<Exif::ByteOrder>))����������������ͤǤ���
|
87
|
+
|
88
|
+
--- Exif#ifd
|
89
|
+
|
90
|
+
���ߤ�IFD(Image File Directory)��ʸ������֤��ޤ���
|
91
|
+
|
92
|
+
--- Exif#ifd=(ifd)
|
93
|
+
|
94
|
+
IFD(Image File Directory)�����ꤷ�ޤ���((|ifd|))��((<Exif::IFD>))�ʲ�����������������Ѥ��Ʋ�������
|
95
|
+
|
96
|
+
--- Exif#[](tag)
|
97
|
+
|
98
|
+
���Ƥ�IFD���Ϥä�Ϳ����줿����(({tag}))��Ĵ�١�������б������ͤ�ʸ������֤��ޤ�����������((<Exif#ifd=>))������Ū��IFD����ꤷ����ϡ�����IFD�ˤ����ƥ������������Ƥ���С��б������ͤ��֤��ޤ����������Ƥ��ʤ����ˤϡ��㳰((<Exif::Error::TagNotFound>))��ȯ�����ޤ������ư����ᤷ�������ϡ�((<Exif#ifd=>))��((<Exif::IFD::Any>))����ꤷ�Ʋ�������
|
99
|
+
|
100
|
+
--- Exif#each_entry(use_tag_id=false) {|tag, value| ...}
|
101
|
+
|
102
|
+
������˴ޤޤ�륿���Υ����ȥ��(({tag}))���ͤ�(({tag}))�Ȥ��ơ��֥��å���¹Ԥ��ޤ���((|use_tag_id|))��(({true}))�ΤȤ���(({tag}))�ˤϥ�����ID('0xdddd'ɽ��)����������ޤ���
|
103
|
+
|
104
|
+
--- Exif#extract_thumbnail(dest)
|
105
|
+
--- Exif#thumbnail(dest)
|
106
|
+
|
107
|
+
������˴ޤޤ�륵��ͥ����((|dest|))��(({dest#<<}))���Ѥ��ƽ��ߤޤ���
|
108
|
+
|
109
|
+
== �⥸�塼��
|
110
|
+
|
111
|
+
== Exif::IFD
|
112
|
+
|
113
|
+
IFD�μ����ɽ�����
|
114
|
+
|
115
|
+
--- Exif::IFD::Zero
|
116
|
+
--- Exif::IFD::One
|
117
|
+
--- Exif::IFD::EXIF
|
118
|
+
--- Exif::IFD::GPS
|
119
|
+
--- Exif::IFD::Interoperability
|
120
|
+
--- Exif::IFD::Any
|
121
|
+
|
122
|
+
== Exif::ByteOrder
|
123
|
+
|
124
|
+
EXIF������ΥХ��ȥ���������ɽ�����
|
125
|
+
|
126
|
+
--- Exif::ByteOrder::INTEL
|
127
|
+
--- Exif::ByteOrder::MOTOROLA
|
128
|
+
|
129
|
+
== �㳰���饹
|
130
|
+
|
131
|
+
RuntimeError --- Exif::Error -+- Exif::Error::NotExifFormat
|
132
|
+
|- Exif::Error::InvalidIFD
|
133
|
+
`- Exif::Error::TagNotFound
|
134
|
+
--- Exif::Error
|
135
|
+
|
136
|
+
ruby-libexif�������㳰�����Ƥ����㳰�����ޤ��ϰʲ��Υ��֥��饹���㳰��°���ޤ���
|
137
|
+
|
138
|
+
--- Exif::Error::ExifFormat
|
139
|
+
|
140
|
+
Ϳ����줿�������EXIF�ե����ޥåȤ�Ŭ�礷�Ƥ��ʤ���硢�����㳰��ȯ�����ޤ���
|
141
|
+
|
142
|
+
--- Exif::Error::InvalidIFD
|
143
|
+
|
144
|
+
((<Exif#ifd=>))�ǡ�������IFD����ꤷ�����ˡ������㳰��ȯ�����ޤ���
|
145
|
+
|
146
|
+
--- Exif::Error::TagNotFound
|
147
|
+
|
148
|
+
((<Exif#[]>))�ǡ�Tag�����ߤ�IFD�Ǹ��Ĥ���ʤ��ä����ˡ������㳰��ȯ�����ޤ���
|
149
|
+
|
150
|
+
--- Exif::Error::ThumbnailNotFound
|
151
|
+
|
152
|
+
((<Exif#thumbnail>))�ǡ�������˥���ͥ��뤬�ޤޤ�ʤ����ˡ������㳰��ȯ�����ޤ���
|
153
|
+
|
154
|
+
=end
|
data/ext/extconf.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
dir_config("exif", "/usr/local/include", "/usr/local/lib")
|
4
|
+
|
5
|
+
def have_libexif_header
|
6
|
+
have_header('libexif/exif-ifd.h') and
|
7
|
+
have_header('libexif/exif-data.h') and
|
8
|
+
have_header('libexif/exif-utils.h') and
|
9
|
+
have_header('libexif/exif-tag.h')
|
10
|
+
end
|
11
|
+
|
12
|
+
if have_libexif_header and have_library("exif")
|
13
|
+
create_makefile("exif")
|
14
|
+
end
|
15
|
+
|
data/lib/extexif.rb
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
# An ExtExif is to use EXIF data from Ruby.
|
2
|
+
# This class is ruby-libexif wrapper, and you can access to Exif field with EXIF tag name of Tag ID.
|
3
|
+
#
|
4
|
+
# EXIF Tags:
|
5
|
+
# * English - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
|
6
|
+
# * Japanese - http://cachu.xrea.jp/perl/ExifTAG.html
|
7
|
+
#
|
8
|
+
# == Examples
|
9
|
+
# require 'extexif'
|
10
|
+
#
|
11
|
+
# images = ExtExif.new('sample.jpg')
|
12
|
+
# images.attribute("GPSLongitude") # => "139.00, 41.00, 17.19"
|
13
|
+
# images["GPSLongitude"] # => "139.00, 41.00, 17.19" - This is synonim.
|
14
|
+
# images.attribute("GPSLatitude") # => "35.00, 39.00, 45.38"
|
15
|
+
# images["GPSLatitude"] # => "35.00, 39.00, 45.38"
|
16
|
+
#
|
17
|
+
require 'exif.so'
|
18
|
+
class ExtExif
|
19
|
+
VERSION = '1.0.0'
|
20
|
+
|
21
|
+
# Exif data
|
22
|
+
# {{{
|
23
|
+
TAGID = {"DNGColorMatrix1"=>50721, "EXFilter"=>3312311, "OLZoom"=>3104109, "MLTFolderName"=>3700003, "DNGColorMatrix2"=>50722,
|
24
|
+
"CNLensMinimum"=>4000001, "PXOTimeZone"=>3404096, "PXOCaptureMode"=>3400001, "Artist"=>315, "CNDigitalZoom"=>4000001,
|
25
|
+
"OLSharpnessFactor"=>3104138, "DigitalZoomRatio"=>41988, "LightSource"=>37384, "MLTDate"=>3700003, "SubjectDistanceRange"=>41996,
|
26
|
+
"TransferFunction"=>301, "SGJpegQuality"=>3800022, "DNGMakerNoteSafety"=>50741, "InteroperabilityIndex"=>2000000, "MLTAperture"=>3700003,
|
27
|
+
"MLTThumbnail"=>3700129, "SGSharpness"=>3800017, "NKColorMode"=>3500003, "MLTLensID"=>3700268, "MLTColorMode"=>3700003,
|
28
|
+
"MLTFileNumberMemory"=>3700003, "EXObjectDistance"=>3308226, "PXOISOSpeed"=>3400020, "FNumber"=>33437, "CompressedBitsPerPixel"=>37122,
|
29
|
+
"Compression"=>259, "GPSDestDistanceRef"=>1000025, "NKAdapter"=>3500130, "NKEColorMode"=>3600004, "GPSTrack"=>1000015, "ImageWidth"=>256,
|
30
|
+
"ShutterSpeedValue"=>37377, "MLTSpotFocusPointX"=>3700003, "PXOContrast"=>3400012, "NKLendID"=>3500152, "MLTSpotFocusPointY"=>3700003,
|
31
|
+
"Saturation"=>41993, "NKManualFocusDistance"=>3500133, "CNLensID"=>4000001, "Contrast"=>41992, "OLExposureBias"=>3104102, "OLSpecialMode"=>3100512,
|
32
|
+
"DNGBlackLevel"=>50714, "DNGPrivateData"=>50740, "EXCCDSensitivity"=>3312308, "RowsPerStrip"=>278, "SubSecTimeDegitized"=>37522,
|
33
|
+
"NKColorOffset"=>3500146, "DNGCameraCalibration1"=>50723, "PXOWhiteBalance"=>3400007, "BitsPerSample"=>258, "MLTMeteringMode"=>3700003,
|
34
|
+
"DNGCameraCalibration2"=>50724, "CNNDFilter"=>4000004, "CNWhitebalance"=>4000004, "YCbCrSubSampling"=>530, "SubSecTimeOriginal"=>37521,
|
35
|
+
"MLTIntervalNumber"=>3700003, "0xa500"=>42240, "GPSDestBearingRef"=>1000023, "DNGBaselineNoise"=>50731, "CNSharpness"=>4000001, "GPSMapDatum"=>1000018,
|
36
|
+
"OLFlashMode"=>3104100, "DNGAsShotNeutral"=>50728, "NKWhitebalance"=>3500005, "OLWhiteBalance"=>3104117, "FJMacro"=>4604128, "PXOSharpness"=>3400011,
|
37
|
+
"CNMacroMode"=>4000001, "MLTFlashFired"=>3700003, "DateTimeOriginal"=>36867, "FocalPlaneResolutionUnit"=>41488, "EXContrast"=>3300032,
|
38
|
+
"SpectralSensitivity"=>34852, "EXTimeZone"=>3312294, "EXThumbnail"=>3308192, "CNImageEffect"=>4000001, "DNGReductionMatrix1"=>50725, "CNFirmware"=>4000007,
|
39
|
+
"CNExposure"=>4000004, "CRSChromaticAberrationB"=>3000022, "DNGReductionMatrix2"=>50726, "GPSDestDistance"=>1000026, "CRSTint"=>3000005, "EXColorMode"=>3312309,
|
40
|
+
"FocalPlaneXResolution"=>41486, "CNAFStopButton"=>4000015, "SubjectLocation"=>41492, "NKColorSpace"=>3500141, "FJFocusMode"=>4604129, "FJQuality"=>4604096,
|
41
|
+
"CNAFPointUsed"=>4000004, "CNFlashDetailed"=>4000001, "MLTBWFilter"=>3700003, "NKWhiteBalanceOffset"=>3500011, "FileSource"=>41728, "DNGShadowScale"=>50739,
|
42
|
+
"MLTIntervalLength"=>3700003, "MLTWhiteBalance"=>3700003, "NKNoiseReduction"=>3500149, "ImageDescription"=>270, "PXFNumber"=>3200019,
|
43
|
+
"SGExposureMode"=>3800008, "PXLensID"=>3200063, "NKShotCount"=>3500167, "CNAFSupliment"=>4000015, "YResolution"=>283,
|
44
|
+
"DNGCalibrationIlluminant1"=>50778, "0xa420"=>42016, "MLTFilmSpeed"=>3700003, "Make"=>271, "DNGCalibrationIlluminant2"=>50779,
|
45
|
+
"NKAFFocusPoint"=>3500136, "FJColor"=>4604099, "OLDigitalZoom"=>3100516, "YCbCrPositioning"=>531, "MLTColorFilter"=>3700003, "WhitePoint"=>318,
|
46
|
+
"PXODaylightSavings"=>3404097, "YCbCrCoefficients"=>529, "NKSharpness"=>3500006, "EXColorEnhance"=>3312310, "GPSAltitudeRef"=>5,
|
47
|
+
"FJVersion"=>4600000, "GPSSpeed"=>1000013, "SubjectArea"=>37396, "DNGRawDataUniqueID"=>50781, "OLMacro"=>3100514, "GPSImgDirection"=>1000017,
|
48
|
+
"ExposureMode"=>41986, "CRSLuminanceSmoothing"=>3000016, "SGColorCoordination"=>3800020, "CNFlash"=>4000001, "ModifyDate"=>306,
|
49
|
+
"EXFlash"=>3308210, "EXSelfTimer"=>3312289, "CNFocusMode"=>4000001, "ResolutionUnit"=>296, "MLTShutterSpeed"=>3700003, "DNGAsShotICCProfile"=>50831,
|
50
|
+
"CNFocusSetting"=>4000001, "CRSBlueSaturation"=>3000014, "CRSAutoExposure"=>3000029, "CRSChromaticAberrationR"=>3000021, "CustomRendered"=>41985,
|
51
|
+
"ExifVersion"=>36864, "CRSBrightness"=>3000009, "EXQuality"=>3312290, "FocalLength"=>37386, "ExposureProgram"=>34850, "DNGChromaBlurRadius"=>50737,
|
52
|
+
"MLTContrast"=>3700003, "DNGActiveArea"=>50829, "NKLensSetting"=>3500131, "GPSLatitude"=>2, "SGAFMode"=>3800005, "ColorSpace"=>40961,
|
53
|
+
"FocalLengthIn35mmFilm"=>41989, "NKEWhiteBalance"=>3600007, "SubSecTime"=>37520, "DeviceSettingDescription"=>41995, "SceneType"=>41729,
|
54
|
+
"CRSVignetteAmount"=>3000023, "GPSSpeedRef"=>1000012, "EXSaturation"=>3300031, "NKContrastSetting"=>3500129, "GPSImgDirectionRef"=>1000016,
|
55
|
+
"EXRecordMode"=>3312288, "FJAEWarning"=>4604866, "CNShutterStep"=>4000015, "MLTFocusArea"=>3700003, "SGShadow"=>3800014, "MLTSharpness"=>3700003,
|
56
|
+
"FJSlowSync"=>4604144, "CNFlashMemLimit"=>4000015, "CNSerial"=>4000012, "CRSRedHue"=>3000017, "ApertureValue"=>37378, "DNGOriginalRawFileData"=>50828,
|
57
|
+
"MLTMacroMode"=>3700003, "CRSTemperature"=>3000004, "FJFlashMode"=>4604112, "CRSLens"=>3000024, "CFAPattern"=>41730, "SGFocalLength"=>3800010,
|
58
|
+
"OLMacroFocus"=>3104110, "MLTWhiteBalanceRed"=>3700003, "NKEDigitalZoom"=>3600010, "DNGVersion"=>50706, "SGFocusMode"=>3800006, "CNFocusType"=>4000001,
|
59
|
+
"CRSExposure"=>3000007, "EXWhiteBalance"=>3300025, "PXExposureBias"=>3200022, "InteroperabilityIFDPointer"=>40965, "ReferenceBlackWhite"=>532,
|
60
|
+
"Model"=>272, "JPEGInterchangeFormat"=>513, "MLTThumbnailOffset"=>3700136, "SGSoftware"=>3800024, "CNImageType"=>4000006, "RelatedSoundFile"=>40964,
|
61
|
+
"PXODigitalZoom"=>3400010, "DNGBestQualityScale"=>50780, "DNGAnalogBalance"=>50727, "MLTMakerNoteVersion"=>3700000, "GPSDestBearing"=>1000024,
|
62
|
+
"SGSaturation"=>3800016, "PXOFocusMode"=>3400003, "MLTLastFileNumber"=>3700003, "PixelYDimension"=>40963, "SGImageSize"=>3800004,
|
63
|
+
"GPSDestLongitude"=>1000022, "Flash"=>37385, "DNGBackwardVersion"=>50707, "OLBlueBias"=>3104120, "PlanarConfiguration"=>284, "NKQuality"=>3500004,
|
64
|
+
"ExposureBiasValue"=>37380, "DNGBayerGreenSplit"=>50733, "GPSMessureMode"=>1000010, "GPSDateStamp"=>1000029, "SamplesPerPixel"=>277,
|
65
|
+
"DNGAsShotWhiteXY"=>50729, "PrimaryChromaticities"=>319, "CNAperture"=>4000004, "PXWhiteBalance"=>3200025, "CRSSharpness"=>3000015,
|
66
|
+
"SGFirmware"=>3800023, "PixelXDimension"=>40962, "GPSProcessingMethod"=>1000027, "GPSTrackRef"=>1000014, "FJBlurWarning"=>4604864,
|
67
|
+
"FJWhiteBalance"=>4604098, "GPSAreaInformation"=>1000028, "OLFocusDistance"=>3104108, "MLTDECPosition"=>3700003, "CRSSaturation"=>3000011,
|
68
|
+
"OLColourMatrix"=>3130, "OLSharpness"=>3104111, "OLRedBias"=>3104119, "NKFlashMode"=>3500009, "MLTunknown16"=>3700003, "SensingMethod"=>41495,
|
69
|
+
"MLTFocalLength"=>3700003, "MLTCameraSettings"=>3703840, "CRSAutoContrast"=>3000028, "EXPIM"=>3303584, "PXISOSpeed"=>3200020, "CRSRawFileName"=>3000001,
|
70
|
+
"CNNoiseReduction"=>4000015, "MLTPIMInformation"=>3703584, "OLImageWidth"=>3104142, "SGWhiteBalance"=>3800007, "CNColorTemp"=>4000160,
|
71
|
+
"CNApexPriority"=>4000015, "SGX3FillLight"=>3800018, "CNSelfTimer"=>4000001, "Orientation"=>274, "MLTFocusMode"=>3700003,
|
72
|
+
"MLTExposureMode"=>3700003, "OLValidBits"=>3104140, "KCMode"=>9900001, "MLTComppressImageSize"=>3700064, "StripByteCounts"=>279,
|
73
|
+
"DNGCameraSerialNumber"=>50735, "PXOColorMode"=>3400023, "MakerNote"=>37500, "DNGAsShotPreProfileMatrix"=>50832, "CNUser"=>4000009,
|
74
|
+
"CRSColorNoiseReduction"=>3000020, "NKEImageAdjustment"=>3600005, "CNImageNumber"=>4000004, "DNGCFALayout"=>50711, "GPSLongitudeRef"=>3,
|
75
|
+
"NKLensInfo"=>3500132, "CRSWhiteBalance"=>3000003, "CNImageSelect"=>4000001, "XResolution"=>282, "DNGLensInfo"=>50736, "WhiteBalance"=>41987,
|
76
|
+
"MLTImageSize"=>3700003, "MeteringMode"=>37383, "MLTMaxAperture"=>3700003, "NKEFocus"=>3600008, "MLTBrightnessValue"=>3700003,
|
77
|
+
"NKDigitalImgProg"=>3500171, "CNColorSpace"=>4000180, "CRSContrast"=>3000010, "DNGLinearizationTable"=>50712, "NKFinishSetting"=>3500169,
|
78
|
+
"MLTExposureCompensation"=>3700003, "GPSLatitudeRef"=>1, "FJFlashStrength"=>4604113, "DNGDefaultCropOrigin"=>50719, "GPSDestLatitudeRef"=>1000019,
|
79
|
+
"CRSGreenSaturation"=>3000013, "UserComment"=>37510, "MLTFlashMode"=>3700003, "NKISOselection"=>3500015, "Sharpness"=>41994,
|
80
|
+
"DNGAntiAliasStrength"=>50738, "SGCustomSettingMode"=>3800021, "OLCameraID"=>3100521, "OLContrast"=>3104137, "DNGDefaultCropSize"=>50720,
|
81
|
+
"DNGLinearResponseLimit"=>50734, "CNAFPoint"=>4000001, "DNGBaselineExposure"=>50730, "ISOSpeedRatings"=>34855, "CNButtunFunction"=>4000015,
|
82
|
+
"DNGCurrentICCProfile"=>50833, "CRSAutoBrightness"=>3000026, "MLTImageQuality"=>3700003, "DNGOriginalRawFileName"=>50827,
|
83
|
+
"PhotometricInterpretation"=>262, "CRSBlueHue"=>3000019, "GPSDOP"=>1000011, "MLTSaturation"=>3700003, "FJContBlacket"=>4604352,
|
84
|
+
"SGSerialID"=>3800002, "CRSShadowTint"=>3000006, "DNGBaselineSharpness"=>50732, "EXFocusMode"=>3312291, "CRSGreenHue"=>3000018,
|
85
|
+
"OLSerialNumber"=>3104122, "MLTISOSetting"=>3700003, "MetadataDate"=>36868, "MLTDigitalZoom"=>3700003, "MLTWideFocusZone"=>3700003,
|
86
|
+
"GPSStatus"=>9, "GPSLongitude"=>4, "FJPictureMode"=>4604145, "EXISOSensitivity"=>3300020, "EXImageSize"=>3300009,
|
87
|
+
"CNFlashBias"=>4000004, "MLTDriveMode"=>3700003, "MaxApertureValue"=>37381, "ExposureTime"=>33434, "GainControl"=>41991, "MLTInternalFlash"=>3700003,
|
88
|
+
"SGHighlight"=>3800015, "OLSoftwareRelease"=>3100519, "CNLensMaximum"=>4000001, "PXOQualityLevel"=>3400002, "MLTFocusDistance"=>3700003,
|
89
|
+
"FJSharpness"=>4604097, "DNGBlackLevelRepeatDim"=>50713, "PXOSaturation"=>3400013, "SGContrast"=>3800013, "DNGUniqueCameraModel"=>50708,
|
90
|
+
"GPSAltitude"=>6, "BrightnessValue"=>37379, "CNMirrorLockUp"=>4000015, "SpatialFrequencyResponse"=>41484, "MLTThumbnailLength"=>3700137,
|
91
|
+
"CNMenuPosition"=>4000015, "NKISOSetting"=>3500002, "OLFocusMode"=>3104107, "ComponentsConfiguration"=>37121, "OLCoringFilter"=>3104141}
|
92
|
+
# }}}
|
93
|
+
|
94
|
+
attr_accessor :image
|
95
|
+
|
96
|
+
class ExifError < StandardError #:nodoc:
|
97
|
+
end
|
98
|
+
class FileNotFoundError < ExifError #:nodoc:
|
99
|
+
end
|
100
|
+
|
101
|
+
# Create new EXIF image instance.
|
102
|
+
# If file is dont't exist when throw ExtExif::FileNotFounedError.
|
103
|
+
#
|
104
|
+
# Parameters:
|
105
|
+
# * path - Path for image file.
|
106
|
+
def initialize(path)
|
107
|
+
raise FileNotFound, "#{path} not found." unless File.exists?(path)
|
108
|
+
@image = Exif.new(path)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Grub the EXIF data.
|
112
|
+
# if Exif data is empty when return nil.
|
113
|
+
#
|
114
|
+
# Parameters:
|
115
|
+
# * name_or_id - EXIF Tag name or EXIF Tag id
|
116
|
+
#
|
117
|
+
# == Examples
|
118
|
+
# images = ExtExif.new('sample.jpg')
|
119
|
+
# images.attribute("GPSLongitude") # => 139.00, 41.00, 17.19
|
120
|
+
# images["GPSLongitude"] # => 139.00, 41.00, 17.19, - This is synonim.
|
121
|
+
# images.attribute("GPSLatitude") # =>
|
122
|
+
# images["GPSLongitude"] # =>
|
123
|
+
#
|
124
|
+
def attribute(name_or_id)
|
125
|
+
tagid = name_or_id.kind_of?(Numeric)? name_or_id : TAGID[name_or_id]
|
126
|
+
tagid.nil? ? nil : @image[tagid]
|
127
|
+
end
|
128
|
+
alias :[] :attribute
|
129
|
+
|
130
|
+
# Proxy to Exif object
|
131
|
+
def method_missing(name, *args, &block)
|
132
|
+
@image.send(name, *args, &block)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|