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 => "FinePixS2Pro"
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'ext/exif.cpp', line 77
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
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'ext/exif.cpp', line 105
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
181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'ext/exif.cpp', line 181
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
199 200 201 202 203 204 205 206 207 208 |
# File 'ext/exif.cpp', line 199
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
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'ext/exif.cpp', line 154
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
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'ext/exif.cpp', line 124
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?
213 214 215 216 217 218 219 220 221 222 |
# File 'ext/exif.cpp', line 213
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
}
|