Class: Exiv2::Exif
- Inherits:
-
Object
- Object
- Exiv2::Exif
- Defined in:
- ext/exif.cpp
Instance Method Summary collapse
-
#[](key) ⇒ Object
Access exif tag by name.
-
#[]=(key, value) ⇒ Object
@exif = 3024 [] — is a universal accessor.
-
#clear ⇒ Object
Clear all exif data in image.
-
#count ⇒ Object
Count of exif tags in image.
-
#delete(key) ⇒ Object
Delete exif value by it’s name.
-
#each(*args) ⇒ Object
Iterates through all exif tags in image.
-
#empty? ⇒ Boolean
Predicate method.
Instance Method Details
#[](key) ⇒ Object
Access exif tag by name
Exiv2::Image.new("a.jpg").exif["Exif.Image.Model"] => "FinePixS2Pro"
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'ext/exif.cpp', line 83
static VALUE exiv2_exif_get(VALUE self, VALUE key) {
__BEGIN
rbImage* image;
Data_Get_Struct(self, rbImage, image);
VALUE strkey = rb_funcall(key, rb_intern("to_s"), 0);
Exiv2::ExifData &exifData = image->image->exifData();
if(exifData.empty()) {
return Qnil;
}
Exiv2::ExifKey exifKey(STR(strkey));
Exiv2::ExifData::const_iterator pos = exifData.findKey(exifKey);
if (pos == exifData.end()) {
return Qnil;
}
return unmarshall_value(pos->value());
__NIL_END
}
|
#[]=(key, value) ⇒ Object
@exif = 3024 [] — is a universal accessor
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'ext/exif.cpp', line 111
static VALUE exiv2_exif_set(VALUE self, VALUE key, VALUE value) {
__BEGIN
rbImage* image;
Data_Get_Struct(self, rbImage, image);
VALUE strkey = rb_funcall(key, rb_intern("to_s"), 0);
if(!marshall_value(image->image->exifData(), STR(strkey), value)) {
THROW("Couldn't write %s", STR(strkey));
}
image->dirty = true;
return value;
__NIL_END
}
|
#clear ⇒ Object
Clear all exif data in image
187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'ext/exif.cpp', line 187
static VALUE exiv2_exif_clear(VALUE self) {
__BEGIN
rbImage* image;
Data_Get_Struct(self, rbImage, image);
Exiv2::ExifData &exifData = image->image->exifData();
if(exifData.empty()) {
return Qnil;
}
exifData.clear();
return self;
__END
}
|
#count ⇒ Object
Count of exif tags in image
205 206 207 208 209 210 211 212 213 214 |
# File 'ext/exif.cpp', line 205
static VALUE exiv2_exif_count(VALUE self) {
__BEGIN
rbImage* image;
Data_Get_Struct(self, rbImage, image);
Exiv2::ExifData &exifData = image->image->exifData();
return INT2FIX(exifData.count());
__END
}
|
#delete(key) ⇒ Object
Delete exif value by it’s name
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'ext/exif.cpp', line 160
static VALUE exiv2_exif_delete(VALUE self, VALUE key) {
__BEGIN
rbImage* image;
Data_Get_Struct(self, rbImage, image);
VALUE strkey = rb_funcall(key, rb_intern("to_s"), 0);
Exiv2::ExifData &exifData = image->image->exifData();
if(exifData.empty()) {
return Qnil;
}
Exiv2::ExifKey exifKey(STR(strkey));
Exiv2::ExifData::iterator pos = exifData.findKey(exifKey);
if (pos == exifData.end()) {
return Qnil;
}
std::string v = pos->toString();
exifData.erase(pos);
return rb_str_new(v.c_str(), v.length());
__NIL_END
}
|
#each(*args) ⇒ Object
Iterates through all exif tags in image
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'ext/exif.cpp', line 130
static VALUE exiv2_exif_each(int argc, VALUE *argv, VALUE self) {
__BEGIN
rbImage* image;
Data_Get_Struct(self, rbImage, image);
VALUE prefix;
rb_scan_args(argc, argv, "01", &prefix);
Exiv2::ExifData &exifData = image->image->exifData();
if(exifData.empty()) {
return Qnil;
}
Exiv2::ExifData::const_iterator end = exifData.end();
for(Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) {
VALUE key = rb_str_new(i->key().c_str(), i->key().length());
VALUE val = unmarshall_value(i->value());
//VALUE val = rb_str_new(i->toString().c_str(), i->toString().length());
if(prefix != Qnil && INT2FIX(0) != rb_funcall(key, rb_intern("index"), 1, prefix)) {
continue;
}
rb_yield(rb_ary_new3(2, key, val));
}
return self;
__END
}
|
#empty? ⇒ Boolean
Predicate method. Is exif empty?
219 220 221 222 223 224 225 226 227 228 |
# File 'ext/exif.cpp', line 219
static VALUE exiv2_exif_empty(VALUE self) {
__BEGIN
rbImage* image;
Data_Get_Struct(self, rbImage, image);
Exiv2::ExifData &exifData = image->image->exifData();
return exifData.empty() ? Qtrue : Qfalse;
__NIL_END
}
|