Mercurial > geeqie.yaz
comparison src/exif-common.c @ 922:826d5862f671
Minor tidy up.
author | zas_ |
---|---|
date | Wed, 23 Jul 2008 17:38:04 +0000 |
parents | efed9a1520d6 |
children | 8cef771ff0fb |
comparison
equal
deleted
inserted
replaced
921:b416159a5820 | 922:826d5862f671 |
---|---|
87 } | 87 } |
88 | 88 |
89 static double get_crop_factor(ExifData *exif) | 89 static double get_crop_factor(ExifData *exif) |
90 { | 90 { |
91 double res_unit_tbl[] = {0.0, 25.4, 25.4, 10.0, 1.0, 0.001 }; | 91 double res_unit_tbl[] = {0.0, 25.4, 25.4, 10.0, 1.0, 0.001 }; |
92 | |
93 double xres = exif_get_rational_as_double(exif, "Exif.Photo.FocalPlaneXResolution"); | 92 double xres = exif_get_rational_as_double(exif, "Exif.Photo.FocalPlaneXResolution"); |
94 double yres = exif_get_rational_as_double(exif, "Exif.Photo.FocalPlaneYResolution"); | 93 double yres = exif_get_rational_as_double(exif, "Exif.Photo.FocalPlaneYResolution"); |
95 int res_unit; | 94 gint res_unit; |
96 int w, h; | 95 gint w, h; |
97 double xsize, ysize, size, ratio; | 96 double xsize, ysize, size, ratio; |
98 | 97 |
99 if (xres == 0.0 || yres == 0.0) return 0.0; | 98 if (xres == 0.0 || yres == 0.0) return 0.0; |
100 | 99 |
101 if (!exif_get_integer(exif, "Exif.Photo.FocalPlaneResolutionUnit", &res_unit)) return 0.0; | 100 if (!exif_get_integer(exif, "Exif.Photo.FocalPlaneResolutionUnit", &res_unit)) return 0.0; |
124 gint str_len = strlen(str); | 123 gint str_len = strlen(str); |
125 | 124 |
126 if (suffix_len < 0) suffix_len = strlen(suffix); | 125 if (suffix_len < 0) suffix_len = strlen(suffix); |
127 if (str_len < suffix_len) return FALSE; | 126 if (str_len < suffix_len) return FALSE; |
128 | 127 |
129 if (strcmp(str + str_len - suffix_len, suffix) != 0) return FALSE; | 128 if (strcmp(str + str_len - suffix_len, suffix) != 0) return FALSE; |
130 str[str_len - suffix_len] = '\0'; | 129 str[str_len - suffix_len] = '\0'; |
131 | 130 |
132 return TRUE; | 131 return TRUE; |
133 } | 132 } |
134 | 133 |
273 { | 272 { |
274 return g_strdup_printf("%d mm", n); | 273 return g_strdup_printf("%d mm", n); |
275 } | 274 } |
276 | 275 |
277 f = exif_get_rational_as_double(exif, "Exif.Photo.FocalLength"); | 276 f = exif_get_rational_as_double(exif, "Exif.Photo.FocalLength"); |
277 if (f == 0.0) return NULL; | |
278 | |
278 c = get_crop_factor(exif); | 279 c = get_crop_factor(exif); |
279 | 280 if (c == 0.0) return NULL; |
280 if (f != 0.0 && c != 0.0) | 281 |
281 { | 282 return g_strdup_printf("%.0f mm", f * c); |
282 return g_strdup_printf("%.0f mm", f * c); | |
283 } | |
284 | |
285 return NULL; | |
286 } | 283 } |
287 | 284 |
288 static gchar *exif_build_formatted_ISOSpeedRating(ExifData *exif) | 285 static gchar *exif_build_formatted_ISOSpeedRating(ExifData *exif) |
289 { | 286 { |
290 gchar *text; | 287 gchar *text; |
383 | 380 |
384 static gchar *exif_build_formatted_ColorProfile(ExifData *exif) | 381 static gchar *exif_build_formatted_ColorProfile(ExifData *exif) |
385 { | 382 { |
386 const gchar *name = ""; | 383 const gchar *name = ""; |
387 const gchar *source = ""; | 384 const gchar *source = ""; |
388 unsigned char *profile_data; | 385 guchar *profile_data; |
389 guint profile_len; | 386 guint profile_len; |
390 | 387 |
391 profile_data = exif_get_color_profile(exif, &profile_len); | 388 profile_data = exif_get_color_profile(exif, &profile_len); |
392 if (!profile_data) | 389 if (!profile_data) |
393 { | 390 { |
459 { | 456 { |
460 gint i; | 457 gint i; |
461 | 458 |
462 if (key_valid) *key_valid = TRUE; | 459 if (key_valid) *key_valid = TRUE; |
463 | 460 |
464 key = key + 10; | 461 key += 10; |
465 for (i = 0; ExifFormattedList[i].key; i++) | 462 for (i = 0; ExifFormattedList[i].key; i++) |
466 if (strcmp(key, ExifFormattedList[i].key + 10) == 0) | 463 if (strcmp(key, ExifFormattedList[i].key + 10) == 0) |
467 return ExifFormattedList[i].build_func(exif); | 464 return ExifFormattedList[i].build_func(exif); |
468 } | 465 } |
469 | 466 |
471 return NULL; | 468 return NULL; |
472 } | 469 } |
473 | 470 |
474 const gchar *exif_get_description_by_key(const gchar *key) | 471 const gchar *exif_get_description_by_key(const gchar *key) |
475 { | 472 { |
476 gint i; | |
477 | |
478 if (!key) return NULL; | 473 if (!key) return NULL; |
479 | 474 |
480 if (strncmp(key, "formatted.", 10) == 0) | 475 if (strncmp(key, "formatted.", 10) == 0) |
481 { | 476 { |
482 key = key + 10; | 477 gint i; |
478 | |
479 key += 10; | |
483 for (i = 0; ExifFormattedList[i].key; i++) | 480 for (i = 0; ExifFormattedList[i].key; i++) |
484 if (strcmp(key, ExifFormattedList[i].key + 10) == 0) | 481 if (strcmp(key, ExifFormattedList[i].key + 10) == 0) |
485 return _(ExifFormattedList[i].description); | 482 return _(ExifFormattedList[i].description); |
486 } | 483 } |
487 | 484 |
555 break; | 552 break; |
556 } | 553 } |
557 } | 554 } |
558 } | 555 } |
559 | 556 |
560 | |
561 fd->exif = exif_read(fd->path, sidecar_path); | 557 fd->exif = exif_read(fd->path, sidecar_path); |
562 return fd->exif; | 558 return fd->exif; |
563 } | 559 } |
564 | 560 |
565 void exif_free_fd(FileData *fd, ExifData *exif) | 561 void exif_free_fd(FileData *fd, ExifData *exif) |