Mercurial > geeqie.yaz
comparison src/exiv2.cc @ 182:8a417f10ba09
more exiv2 fixes
author | nadvornik |
---|---|
date | Wed, 13 Feb 2008 23:02:48 +0000 |
parents | e6c8cf017d68 |
children | 3962c9d3d6fd |
comparison
equal
deleted
inserted
replaced
181:c01dd7c9c7dc | 182:8a417f10ba09 |
---|---|
22 }; | 22 }; |
23 | 23 |
24 | 24 |
25 ExifData *exif_read(gchar *path, gint parse_color_profile) | 25 ExifData *exif_read(gchar *path, gint parse_color_profile) |
26 { | 26 { |
27 printf("exif %s\n", path); | |
27 try { | 28 try { |
28 ExifData *exif = g_new0(ExifData, 1); | 29 ExifData *exif = new ExifData; |
29 | 30 |
30 Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path); | 31 Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path); |
31 g_assert (image.get() != 0); | 32 g_assert (image.get() != 0); |
32 image->readMetadata(); | 33 image->readMetadata(); |
33 exif->exifData = image->exifData(); | 34 exif->exifData = image->exifData(); |
40 | 41 |
41 } | 42 } |
42 | 43 |
43 void exif_free(ExifData *exif) | 44 void exif_free(ExifData *exif) |
44 { | 45 { |
46 | |
47 delete exif; | |
45 } | 48 } |
46 | 49 |
47 | 50 |
48 gchar *exif_get_data_as_text(ExifData *exif, const gchar *key) | 51 gchar *exif_get_data_as_text(ExifData *exif, const gchar *key) |
49 { | 52 { |
53 gint key_valid; | |
54 gchar *text = exif_get_formatted_by_key(exif, key, &key_valid); | |
55 if (key_valid) return text; | |
56 | |
50 return g_strdup(exif->exifData[key].toString().c_str()); | 57 return g_strdup(exif->exifData[key].toString().c_str()); |
51 } | 58 } |
52 | 59 |
53 gint exif_get_integer(ExifData *exif, const gchar *key, gint *value) | 60 gint exif_get_integer(ExifData *exif, const gchar *key, gint *value) |
54 { | 61 { |
64 { | 71 { |
65 /* Exiv2::Rational v = exif->exifData[key]; | 72 /* Exiv2::Rational v = exif->exifData[key]; |
66 ExifRational *ret = | 73 ExifRational *ret = |
67 return exif->exifData[key]; | 74 return exif->exifData[key]; |
68 */ | 75 */ |
69 } | |
70 | |
71 double exif_rational_to_double(ExifRational *r, gint sign) | |
72 { | |
73 if (!r || r->den == 0.0) return 0.0; | |
74 | |
75 if (sign) return (double)((int)r->num) / (double)((int)r->den); | |
76 return (double)r->num / r->den; | |
77 } | 76 } |
78 | 77 |
79 ExifItem *exif_get_item(ExifData *exif, const gchar *key) | 78 ExifItem *exif_get_item(ExifData *exif, const gchar *key) |
80 { | 79 { |
81 Exiv2::Exifdatum *item = &exif->exifData[key]; | 80 Exiv2::Exifdatum *item = &exif->exifData[key]; |
115 | 114 |
116 char *exif_item_get_data(ExifItem *item, guint *data_len) | 115 char *exif_item_get_data(ExifItem *item, guint *data_len) |
117 { | 116 { |
118 } | 117 } |
119 | 118 |
120 const char *exif_item_get_description(ExifItem *item) | 119 char *exif_item_get_description(ExifItem *item) |
121 { | 120 { |
122 return ((Exiv2::Exifdatum *)item)->tagLabel().c_str(); | 121 return g_strdup(((Exiv2::Exifdatum *)item)->tagLabel().c_str()); |
123 } | 122 } |
124 | 123 |
125 /* | 124 /* |
126 invalidTypeId, unsignedByte, asciiString, unsignedShort, | 125 invalidTypeId, unsignedByte, asciiString, unsignedShort, |
127 unsignedLong, unsignedRational, signedByte, undefined, | 126 unsignedLong, unsignedRational, signedByte, undefined, |
168 | 167 |
169 ExifRational *exif_item_get_rational(ExifItem *item, gint *sign) | 168 ExifRational *exif_item_get_rational(ExifItem *item, gint *sign) |
170 { | 169 { |
171 } | 170 } |
172 | 171 |
173 const gchar *exif_get_description_by_key(const gchar *key) | 172 const gchar *exif_get_tag_description_by_key(const gchar *key) |
174 { | 173 { |
174 Exiv2::ExifKey ekey(key); | |
175 return Exiv2::ExifTags::tagLabel(ekey.tag(), ekey.ifdId ()); | |
175 } | 176 } |
176 | 177 |
177 gint format_raw_img_exif_offsets_fd(int fd, const gchar *path, | 178 gint format_raw_img_exif_offsets_fd(int fd, const gchar *path, |
178 unsigned char *header_data, const guint header_len, | 179 unsigned char *header_data, const guint header_len, |
179 guint *image_offset, guint *exif_offset) | 180 guint *image_offset, guint *exif_offset) |