[argyllcms] Patch to tiffgamut - support embedded profiles.
- From: "Alastair M. Robinson" <profiling@xxxxxxxxxxxxxxxxxxxxxxx>
- To: argyllcms@xxxxxxxxxxxxx
- Date: Sun, 16 Mar 2008 23:39:56 +0000
Hi,
I've been playing a little with the process of using tiffgamut and
icclink to compute devicelinks tailored to a specific image.
From the point of view of including this process in an automated
workflow it would be useful for the tiffgamut utility to make use of
embedded profiles in the TIFF image - so I put together a little patch
to do just that.
The attached patch modifies tiffgamut's behaviour in the following ways:
* If tiffgamut is called as usual with both a profile filename and an
image filename, it will process the image in the normal way. If the
image contains an embedded profile, it will print a warning to say that
the embedded profile is being overriden.
* If the profile filename is omitted, then tiffgamut will use the
embedded profile, if present, and bail out if not.
Hope someone else finds this useful ;)
All the best,
--
Alastair M. Robinson
--- /home/amr/ArgyllBeta/argyll-0.70-beta8_working/xicc/tiffgamut.c
2008-03-16 18:59:17.000000000 +0000
+++ tiffgamut.c 2008-03-16 19:31:05.000000000 +0000
@@ -162,6 +162,9 @@
main(int argc, char *argv[]) {
int fa,nfa; /* argument we're
looking at */
char prof_name[100]; /* Icc profile name */
+ int embeddedprofile = 0; /* Do we have an embedded profile? */
+ char *profilebuffer=NULL; /* Pointer to profile buffer, if found
*/
+ int profilelen=0; /* embedded profile's length,
if found */
char in_name[100]; /* TIFF input file */
char *xl, out_name[100]; /* VRML output file */
@@ -365,15 +368,42 @@
}
if (fa >= argc || argv[fa][0] == '-') usage();
- strcpy(prof_name,argv[fa++]);
+ /* If there's only one remaining argument we'll consider it the TIFF
filename
+ since the TIFF may have an embedded profile. */
+ if (fa==(argc-1)) {
+ prof_name[0]=0;
+ strcpy(in_name,argv[fa++]);
+ }
+ else {
+ strcpy(prof_name,argv[fa++]);
+ strcpy(in_name,argv[fa++]);
+ }
- if (fa >= argc || argv[fa][0] == '-') usage();
- strcpy(in_name,argv[fa++]);
+ /* Open the TIFF file, and check for embedded profile */
+ if ((rh = TIFFOpen(in_name, "r")) == NULL)
+ error("error opening read file '%s'",in_name);
- /* - - - - - - - - - - - - - - - - */
- /* Open up the profile for reading */
- if ((p_fp = new_icmFileStd_name(prof_name,"r")) == NULL)
- error ("Can't open file '%s'",prof_name);
+ if(TIFFGetField(rh, TIFFTAG_ICCPROFILE, &profilelen, &profilebuffer))
+ embeddedprofile=1;
+
+ if(prof_name[0]) { /* Was a profile filename supplied? */
+ if(embeddedprofile)
+ warning("Overriding an embedded profile.");
+
+ /* Open up the profile for reading from disk */
+ if ((p_fp = new_icmFileStd_name(prof_name,"r")) == NULL)
+ error ("Can't open file '%s'",prof_name);
+ }
+ else { /* No profile supplied - but that's OK if the TIFF has one
embedded */
+ if(embeddedprofile)
+ {
+ /* Open up the embedded profile from memory */
+ if ((p_fp = new_icmFileMem(profilebuffer,profilelen))
== NULL)
+ error ("Can't open embedded profile");
+ }
+ else /* No embedded and no supplied profile - so bail out */
+ usage();
+ }
if ((icco = new_icc()) == NULL)
error ("Creation of ICC object failed");
@@ -447,11 +477,9 @@
luo->spaces(luo, &ins, &inn, &outs, &outn, &alg, NULL, NULL, NULL);
- /* - - - - - - - - - - - - - - - */
- /* Open up input tiff file ready for reading */
+ /* - - - - - - - - - - - - - - - - */
+ /* Continue processing tiff file. */
/* Got arguments, so setup to process the file */
- if ((rh = TIFFOpen(in_name, "r")) == NULL)
- error("error opening read file '%s'",in_name);
TIFFGetField(rh, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetField(rh, TIFFTAG_IMAGELENGTH, &height);
- Follow-Ups:
- [argyllcms] Re: Patch to tiffgamut - support embedded profiles.
- From: Kai-Uwe Behrmann
Other related posts:
- » [argyllcms] Patch to tiffgamut - support embedded profiles.
- » [argyllcms] Re: Patch to tiffgamut - support embedded profiles.
- » [argyllcms] Re: Patch to tiffgamut - support embedded profiles.
- » [argyllcms] Re: Patch to tiffgamut - support embedded profiles.
- » [argyllcms] Re: Patch to tiffgamut - support embedded profiles.
- [argyllcms] Re: Patch to tiffgamut - support embedded profiles.
- From: Kai-Uwe Behrmann