Mercurial > geeqie.yaz
comparison src/image.c @ 449:115db540bd0c
read color profiles from jpeg also with Exiv2
author | nadvornik |
---|---|
date | Sun, 20 Apr 2008 21:35:03 +0000 |
parents | ddabc4873a3f |
children | 48c8e49b571c |
comparison
equal
deleted
inserted
replaced
448:a73cc0fa14d0 | 449:115db540bd0c |
---|---|
333 ColorMan *cm; | 333 ColorMan *cm; |
334 ColorManProfileType input_type; | 334 ColorManProfileType input_type; |
335 ColorManProfileType screen_type; | 335 ColorManProfileType screen_type; |
336 const gchar *input_file; | 336 const gchar *input_file; |
337 const gchar *screen_file; | 337 const gchar *screen_file; |
338 ExifItem *item = NULL; | 338 unsigned char *profile = NULL; |
339 guint profile_len; | |
339 | 340 |
340 if (imd->cm) return FALSE; | 341 if (imd->cm) return FALSE; |
341 | 342 |
342 if (imd->color_profile_input >= COLOR_PROFILE_FILE && | 343 if (imd->color_profile_input >= COLOR_PROFILE_FILE && |
343 imd->color_profile_input < COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS) | 344 imd->color_profile_input < COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS) |
378 } | 379 } |
379 imd->color_profile_from_image = COLOR_PROFILE_NONE; | 380 imd->color_profile_from_image = COLOR_PROFILE_NONE; |
380 | 381 |
381 if (imd->color_profile_use_image && exif) | 382 if (imd->color_profile_use_image && exif) |
382 { | 383 { |
383 item = exif_get_item(exif, "Exif.Image.InterColorProfile"); | 384 profile = exif_get_color_profile(exif, &profile_len); |
384 if (!item) | 385 if (!profile) |
385 { | 386 { |
386 gint cs; | 387 gint cs; |
387 gchar *interop_index; | 388 gchar *interop_index; |
388 | 389 |
389 /* ColorSpace == 1 specifies sRGB per EXIF 2.2 */ | 390 /* ColorSpace == 1 specifies sRGB per EXIF 2.2 */ |
409 | 410 |
410 g_free(interop_index); | 411 g_free(interop_index); |
411 } | 412 } |
412 } | 413 } |
413 | 414 |
414 if (item && exif_item_get_format_id(item) == EXIF_FORMAT_UNDEFINED) | 415 if (profile) |
415 { | 416 { |
416 unsigned char *data; | |
417 guint data_len; | |
418 if (debug) printf("Found embedded color profile\n"); | 417 if (debug) printf("Found embedded color profile\n"); |
419 imd->color_profile_from_image = COLOR_PROFILE_MEM; | 418 imd->color_profile_from_image = COLOR_PROFILE_MEM; |
420 | 419 |
421 data = (unsigned char *) exif_item_get_data(item, &data_len); | |
422 | |
423 cm = color_man_new_embedded(run_in_bg ? imd : NULL, NULL, | 420 cm = color_man_new_embedded(run_in_bg ? imd : NULL, NULL, |
424 data, data_len, | 421 profile, profile_len, |
425 screen_type, screen_file); | 422 screen_type, screen_file); |
426 g_free(data); | 423 g_free(profile); |
427 } | 424 } |
428 else | 425 else |
429 { | 426 { |
430 cm = color_man_new(run_in_bg ? imd : NULL, NULL, | 427 cm = color_man_new(run_in_bg ? imd : NULL, NULL, |
431 input_type, input_file, | 428 input_type, input_file, |
460 if (debug) printf("%s image postprocess: %s\n", get_exec_time(), imd->image_fd->name); | 457 if (debug) printf("%s image postprocess: %s\n", get_exec_time(), imd->image_fd->name); |
461 | 458 |
462 if (options->image.exif_rotate_enable || | 459 if (options->image.exif_rotate_enable || |
463 (imd->color_profile_enable && imd->color_profile_use_image) ) | 460 (imd->color_profile_enable && imd->color_profile_use_image) ) |
464 { | 461 { |
465 exif = exif_read_fd(imd->image_fd, (imd->color_profile_enable && imd->color_profile_use_image)); | 462 exif = exif_read_fd(imd->image_fd); |
466 } | 463 } |
467 if (options->image.exif_rotate_enable && exif) | 464 if (options->image.exif_rotate_enable && exif) |
468 { | 465 { |
469 gint orientation; | 466 gint orientation; |
470 | 467 |
729 image_change_pixbuf(imd, imd->prev_pixbuf, image_zoom_get(imd)); | 726 image_change_pixbuf(imd, imd->prev_pixbuf, image_zoom_get(imd)); |
730 if (imd->prev_color_row >= 0) | 727 if (imd->prev_color_row >= 0) |
731 { | 728 { |
732 ExifData *exif = NULL; | 729 ExifData *exif = NULL; |
733 | 730 |
734 if (imd->color_profile_use_image) exif = exif_read_fd(imd->image_fd, TRUE); | 731 if (imd->color_profile_use_image) exif = exif_read_fd(imd->image_fd); |
735 // image_post_process_color(imd, imd->prev_color_row, exif, TRUE); | 732 // image_post_process_color(imd, imd->prev_color_row, exif, TRUE); |
736 exif_free(exif); | 733 exif_free(exif); |
737 } | 734 } |
738 success = TRUE; | 735 success = TRUE; |
739 } | 736 } |
1313 | 1310 |
1314 if (read_exif_for_color_profile || read_exif_for_orientation) | 1311 if (read_exif_for_color_profile || read_exif_for_orientation) |
1315 { | 1312 { |
1316 gint orientation; | 1313 gint orientation; |
1317 | 1314 |
1318 exif = exif_read_fd(imd->image_fd, read_exif_for_color_profile); | 1315 exif = exif_read_fd(imd->image_fd); |
1319 | 1316 |
1320 if (exif && read_exif_for_orientation) | 1317 if (exif && read_exif_for_orientation) |
1321 { | 1318 { |
1322 if (exif_get_integer(exif, "Exif.Image.Orientation", &orientation)) | 1319 if (exif_get_integer(exif, "Exif.Image.Orientation", &orientation)) |
1323 imd->orientation = orientation; | 1320 imd->orientation = orientation; |