Index: docs/parasites.txt =================================================================== RCS file: /cvs/gnome/gimp/docs/parasites.txt,v retrieving revision 1.14 diff -u -u -r1.14 parasites.txt --- docs/parasites.txt 2000/03/12 00:17:28 1.14 +++ docs/parasites.txt 2000/06/10 00:39:00 @@ -121,6 +121,13 @@ 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. At this time only an + experimental color manager plugin can use this parasite, but + it's better to store it now than to be sorry later. + ------------------------------------------------------------------ Index: plug-ins/common/tiff.c =================================================================== RCS file: /cvs/gnome/gimp/plug-ins/common/tiff.c,v retrieving revision 1.46 diff -u -u -r1.46 tiff.c --- plug-ins/common/tiff.c 2000/05/26 22:28:35 1.46 +++ plug-ins/common/tiff.c 2000/06/10 00:39:01 @@ -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 @@ 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 @@ } 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; @@ -1395,6 +1417,27 @@ gimp_parasite_free (parasite); } #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);