Class: Exiv2::Iptc
- Inherits:
-
Object
- Object
- Exiv2::Iptc
- Defined in:
- ext/iptc.cpp
Instance Method Summary collapse
-
#[](key) ⇒ Object
Access iptc tag by name.
-
#[]=(key, value) ⇒ Object
@iptc = “GreeenDude” [] — is a universal accessor.
-
#clear ⇒ Object
Clear all iptc data in image.
-
#count ⇒ Object
Count of iptc tags in image.
-
#delete(key) ⇒ Object
Delete iptc value by it’s name.
-
#each(*args) ⇒ Object
Iterates through all iptc tags in image.
-
#empty? ⇒ Boolean
Predicate method.
Instance Method Details
#[](key) ⇒ Object
Access iptc tag by name
Exiv2::Image.new("test/data/smiley.jpg").iptc["Iptc.Application2.ObjectName"] => "GreeenDude"
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'ext/iptc.cpp', line 89
static VALUE exiv2_iptc_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::IptcData &iptcData = image->image->iptcData();
if(iptcData.empty()) {
return Qnil;
}
Exiv2::IptcKey iptcKey(STR(strkey));
Exiv2::IptcData::const_iterator pos = iptcData.findKey(iptcKey);
if (pos == iptcData.end()) {
return Qnil;
}
return unmarshall_value(pos->value());
__NIL_END
}
|
#[]=(key, value) ⇒ Object
@iptc = “GreeenDude” [] — is a universal accessor
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'ext/iptc.cpp', line 116
static VALUE exiv2_iptc_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->iptcData(), STR(strkey), value)) {
THROW("Couldn't write %s", STR(strkey));
}
image->dirty = true;
return value;
__NIL_END
}
|
#clear ⇒ Object
Clear all iptc data in image
195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'ext/iptc.cpp', line 195
static VALUE exiv2_iptc_clear(VALUE self) {
__BEGIN
rbImage* image;
Data_Get_Struct(self, rbImage, image);
Exiv2::IptcData &iptcData = image->image->iptcData();
if(iptcData.empty()) {
return Qnil;
}
iptcData.clear();
return self;
__END
}
|
#count ⇒ Object
Count of iptc tags in image
213 214 215 216 217 218 219 220 221 222 |
# File 'ext/iptc.cpp', line 213
static VALUE exiv2_iptc_count(VALUE self) {
__BEGIN
rbImage* image;
Data_Get_Struct(self, rbImage, image);
Exiv2::IptcData &iptcData = image->image->iptcData();
return INT2FIX(iptcData.count());
__END
}
|
#delete(key) ⇒ Object
Delete iptc value by it’s name
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'ext/iptc.cpp', line 167
static VALUE exiv2_iptc_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::IptcData &iptcData = image->image->iptcData();
if(iptcData.empty()) {
return Qnil;
}
Exiv2::IptcKey iptcKey(STR(strkey));
Exiv2::IptcData::iterator pos = iptcData.findKey(iptcKey);
if (pos == iptcData.end()) {
return Qnil;
}
std::string v = pos->toString();
iptcData.erase(pos);
return rb_str_new(v.c_str(), v.length());
__NIL_END
}
|
#each(*args) ⇒ Object
Iterates through all iptc tags in image
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'ext/iptc.cpp', line 137
static VALUE exiv2_iptc_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::IptcData &iptcData = image->image->iptcData();
if(iptcData.empty()) {
return Qnil;
}
Exiv2::IptcData::const_iterator end = iptcData.end();
for(Exiv2::IptcData::const_iterator i = iptcData.begin(); i != end; ++i) {
VALUE key = rb_str_new(i->key().c_str(), i->key().length());
VALUE val = unmarshall_value(i->value());
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 iptc empty?
227 228 229 230 231 232 233 234 235 236 |
# File 'ext/iptc.cpp', line 227
static VALUE exiv2_iptc_empty(VALUE self) {
__BEGIN
rbImage* image;
Data_Get_Struct(self, rbImage, image);
Exiv2::IptcData &iptcData = image->image->iptcData();
return iptcData.empty() ? Qtrue : Qfalse;
__NIL_END
}
|