diff --git a/ChangeLog b/ChangeLog index 2aaeeee1d2..d311cf06d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2000-05-20 Nick Lamb + + * devel-docs/parasites.txt + * plug-ins/common/tiff.c: Add support for ICC profiles + from look out for equivalent PNG support soon + 2000-06-14 Daniel Egger * paint_funcs.c: Remove calls to tile-acessor functions diff --git a/devel-docs/parasites.txt b/devel-docs/parasites.txt index aa567bb31b..244c60c895 100644 --- a/devel-docs/parasites.txt +++ b/devel-docs/parasites.txt @@ -121,6 +121,13 @@ Global data follows no strict rules. Example: a hot spot at coordinates (5,5) is stored as "5 5" +"icc-profile" (IMAGE, PERSISTENT) + This contains an ICC profile describing the color space the + image was produced in. TIFF images stored in PhotoShop do + oftentimes contain embedded profiles. An experimental color + manager exists to use this parasite, and it will be used + for interchange between TIFF and PNG (identical profiles) + ------------------------------------------------------------------ diff --git a/plug-ins/common/tiff.c b/plug-ins/common/tiff.c index 926f5a6b8d..120d9834e8 100644 --- a/plug-ins/common/tiff.c +++ b/plug-ins/common/tiff.c @@ -8,6 +8,9 @@ * njl195@zepler.org.uk -- 20 April 2000 * The code for this filter is based on "tifftopnm" and "pnmtotiff", * 2 programs that are a part of the netpbm package. + * khk@khk.net -- 13 May 2000 + * Added support for ICCPROFILE tiff tag. If this tag is present in a + * TIFF file, then a parasite is created and vice versa. */ /* @@ -430,6 +433,10 @@ load_image (gchar *filename) GimpParasite *parasite; #endif /* GIMP_HAVE_PARASITES */ guint16 tmp; +#ifdef TIFFTAG_ICCPROFILE + uint32 profile_size; + guchar *icc_profile; +#endif TIFFSetWarningHandler (tiff_warning); TIFFSetErrorHandler (tiff_error); @@ -522,6 +529,21 @@ load_image (gchar *filename) } gimp_image_set_filename (image, filename); + /* attach a parasite containing an ICC profile - if found in the TIFF file */ + +#ifdef TIFFTAG_ICCPROFILE + /* If TIFFTAG_ICCPROFILE is defined we are dealing with a libtiff version + * that can handle ICC profiles. Otherwise just ignore this section. */ + if (TIFFGetField (tif, TIFFTAG_ICCPROFILE, &profile_size, &icc_profile)) { +#ifdef GIMP_HAVE_PARASITES + parasite = parasite_new("icc-profile", 0, + profile_size, icc_profile); + gimp_image_parasite_attach(image, parasite); + parasite_free(parasite); +#endif + } +#endif + /* attach a parasite containing the compression */ if (!TIFFGetField (tif, TIFFTAG_COMPRESSION, &tmp)) save_vals.compression = COMPRESSION_NONE; @@ -1396,6 +1418,27 @@ save_image (gchar *filename, } #endif /* GIMP_HAVE_PARASITES */ + /* do we have an ICC profile? If so, write it to the TIFF file */ +#ifdef GIMP_HAVE_PARASITES +#ifdef TIFFTAG_ICCPROFILE + { + Parasite *parasite; + uint32 profile_size; + guchar *icc_profile; + + parasite = gimp_image_parasite_find (orig_image, "icc-profile"); + if (parasite) + { + profile_size = parasite_data_size(parasite); + icc_profile = parasite_data(parasite); + + TIFFSetField(tif, TIFFTAG_ICCPROFILE, profile_size, icc_profile); + parasite_free(parasite); + } + } +#endif +#endif + if (drawable_type == INDEXED_IMAGE) TIFFSetField (tif, TIFFTAG_COLORMAP, red, grn, blu);