2001-03-01 23:58:53 -05:00
|
|
|
/******************************************************************************
|
|
|
|
* Project: libtiff tools
|
|
|
|
* Purpose: Mainline for setting metadata in existing TIFF files.
|
2005-02-24 09:47:11 -05:00
|
|
|
* Author: Frank Warmerdam, warmerdam@pobox.com
|
2001-03-01 23:58:53 -05:00
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
* Copyright (c) 2000, Frank Warmerdam
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and
|
|
|
|
* its documentation for any purpose is hereby granted without fee, provided
|
|
|
|
* that (i) the above copyright notices and this permission notice appear in
|
|
|
|
* all copies of the software and related documentation, and (ii) the names of
|
|
|
|
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
|
|
|
* publicity relating to the software without the specific, prior written
|
|
|
|
* permission of Sam Leffler and Silicon Graphics.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
|
|
|
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
|
|
|
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
|
|
|
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
|
|
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
|
|
|
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
|
|
* OF THIS SOFTWARE.
|
|
|
|
******************************************************************************
|
|
|
|
*/
|
|
|
|
|
2017-12-02 15:45:03 -05:00
|
|
|
#include "tif_config.h"
|
2001-03-01 23:58:53 -05:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2004-06-05 05:05:26 -04:00
|
|
|
#include "tiffio.h"
|
2001-03-01 23:58:53 -05:00
|
|
|
|
2020-01-25 15:11:05 -05:00
|
|
|
#ifdef NEED_LIBPORT
|
|
|
|
# include "libport.h"
|
|
|
|
#endif
|
|
|
|
|
2020-03-07 10:28:27 -05:00
|
|
|
#ifndef EXIT_SUCCESS
|
|
|
|
#define EXIT_SUCCESS 0
|
|
|
|
#endif
|
|
|
|
#ifndef EXIT_FAILURE
|
|
|
|
#define EXIT_FAILURE 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static const char* usageMsg[] = {
|
2004-06-05 05:05:26 -04:00
|
|
|
"usage: tiffset [options] filename",
|
|
|
|
"where options are:",
|
2004-11-11 06:18:09 -05:00
|
|
|
" -s <tagname> [count] <value>... set the tag value",
|
2012-12-03 22:02:37 -05:00
|
|
|
" -u <tagname> to unset the tag",
|
2011-03-26 08:07:20 -04:00
|
|
|
" -d <dirno> set the directory",
|
|
|
|
" -sd <diroff> set the subdirectory",
|
2004-06-05 05:05:26 -04:00
|
|
|
" -sf <tagname> <filename> read the tag value from file (for ASCII tags only)",
|
2020-03-07 10:28:27 -05:00
|
|
|
" -h this help screen",
|
2004-06-05 05:05:26 -04:00
|
|
|
NULL
|
2001-03-01 23:58:53 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2020-03-07 10:28:27 -05:00
|
|
|
usage(int code)
|
2001-03-01 23:58:53 -05:00
|
|
|
{
|
|
|
|
int i;
|
2020-03-07 10:28:27 -05:00
|
|
|
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
|
|
|
|
|
|
|
|
fprintf(out, "%s\n\n", TIFFGetVersion());
|
2001-03-01 23:58:53 -05:00
|
|
|
for (i = 0; usageMsg[i]; i++)
|
2020-03-07 10:28:27 -05:00
|
|
|
fprintf(out, "%s\n", usageMsg[i]);
|
|
|
|
exit(code);
|
2001-03-01 23:58:53 -05:00
|
|
|
}
|
|
|
|
|
2008-01-01 10:46:28 -05:00
|
|
|
static const TIFFField *
|
2004-10-26 14:22:47 -04:00
|
|
|
GetField(TIFF *tiff, const char *tagname)
|
2004-06-05 05:05:26 -04:00
|
|
|
{
|
2008-01-01 10:46:28 -05:00
|
|
|
const TIFFField *fip;
|
2004-06-05 05:05:26 -04:00
|
|
|
|
|
|
|
if( atoi(tagname) > 0 )
|
|
|
|
fip = TIFFFieldWithTag(tiff, (ttag_t)atoi(tagname));
|
|
|
|
else
|
|
|
|
fip = TIFFFieldWithName(tiff, tagname);
|
|
|
|
|
2004-11-11 06:18:09 -05:00
|
|
|
if (!fip) {
|
2010-07-06 10:30:38 -04:00
|
|
|
fprintf( stderr, "Field name \"%s\" is not recognised.\n", tagname );
|
2008-01-01 10:46:28 -05:00
|
|
|
return (TIFFField *)NULL;
|
2004-06-05 05:05:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return fip;
|
|
|
|
}
|
|
|
|
|
2001-03-01 23:58:53 -05:00
|
|
|
int
|
|
|
|
main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
TIFF *tiff;
|
|
|
|
int arg_index;
|
|
|
|
|
|
|
|
if (argc < 2)
|
2020-03-07 10:28:27 -05:00
|
|
|
usage(EXIT_FAILURE);
|
2001-03-01 23:58:53 -05:00
|
|
|
|
|
|
|
tiff = TIFFOpen(argv[argc-1], "r+");
|
|
|
|
if (tiff == NULL)
|
2020-03-07 10:28:27 -05:00
|
|
|
return EXIT_FAILURE;
|
2001-03-01 23:58:53 -05:00
|
|
|
|
2004-11-11 06:18:09 -05:00
|
|
|
for( arg_index = 1; arg_index < argc-1; arg_index++ ) {
|
2011-03-26 08:07:20 -04:00
|
|
|
if (strcmp(argv[arg_index],"-d") == 0 && arg_index < argc-2) {
|
|
|
|
arg_index++;
|
|
|
|
if( TIFFSetDirectory(tiff, atoi(argv[arg_index]) ) != 1 )
|
|
|
|
{
|
|
|
|
fprintf( stderr, "Failed to set directory=%s\n", argv[arg_index] );
|
2020-03-07 10:28:27 -05:00
|
|
|
return EXIT_FAILURE;
|
2011-03-26 08:07:20 -04:00
|
|
|
}
|
|
|
|
arg_index++;
|
|
|
|
}
|
|
|
|
if (strcmp(argv[arg_index],"-sd") == 0 && arg_index < argc-2) {
|
|
|
|
arg_index++;
|
|
|
|
if( TIFFSetSubDirectory(tiff, atoi(argv[arg_index]) ) != 1 )
|
|
|
|
{
|
|
|
|
fprintf( stderr, "Failed to set sub directory=%s\n", argv[arg_index] );
|
2020-03-07 10:28:27 -05:00
|
|
|
return EXIT_FAILURE;
|
2011-03-26 08:07:20 -04:00
|
|
|
}
|
|
|
|
arg_index++;
|
|
|
|
}
|
2012-12-03 22:02:37 -05:00
|
|
|
/* Add unset option to tiffset -- Zach Baker (niquil@niquil.net) 11/14/2012 */
|
|
|
|
if (strcmp(argv[arg_index],"-u") == 0 && arg_index < argc-2) {
|
|
|
|
const TIFFField *fip;
|
|
|
|
const char *tagname;
|
|
|
|
arg_index++;
|
|
|
|
tagname = argv[arg_index];
|
|
|
|
fip = GetField(tiff, tagname);
|
|
|
|
if (!fip)
|
2020-03-07 10:28:27 -05:00
|
|
|
return EXIT_FAILURE;
|
2012-12-03 22:02:37 -05:00
|
|
|
|
|
|
|
if (TIFFUnsetField(tiff, TIFFFieldTag(fip)) != 1)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Failed to unset %s\n", TIFFFieldName(fip));
|
|
|
|
}
|
|
|
|
arg_index++;
|
|
|
|
} else if (strcmp(argv[arg_index],"-s") == 0 && arg_index < argc-3) {
|
2008-01-01 10:46:28 -05:00
|
|
|
const TIFFField *fip;
|
2004-10-26 14:22:47 -04:00
|
|
|
const char *tagname;
|
2001-03-01 23:58:53 -05:00
|
|
|
|
2004-06-05 05:05:26 -04:00
|
|
|
arg_index++;
|
2004-10-26 14:22:47 -04:00
|
|
|
tagname = argv[arg_index];
|
|
|
|
fip = GetField(tiff, tagname);
|
2001-03-01 23:58:53 -05:00
|
|
|
|
2004-06-05 05:05:26 -04:00
|
|
|
if (!fip)
|
2004-11-11 06:18:09 -05:00
|
|
|
return 3;
|
2004-06-05 05:05:26 -04:00
|
|
|
|
|
|
|
arg_index++;
|
2012-07-29 11:45:29 -04:00
|
|
|
if (TIFFFieldDataType(fip) == TIFF_ASCII) {
|
|
|
|
if (TIFFSetField(tiff, TIFFFieldTag(fip), argv[arg_index]) != 1)
|
2004-06-05 05:05:26 -04:00
|
|
|
fprintf( stderr, "Failed to set %s=%s\n",
|
2012-07-29 11:45:29 -04:00
|
|
|
TIFFFieldName(fip), argv[arg_index] );
|
|
|
|
} else if (TIFFFieldWriteCount(fip) > 0
|
|
|
|
|| TIFFFieldWriteCount(fip) == TIFF_VARIABLE) {
|
2005-09-13 10:09:10 -04:00
|
|
|
int ret = 1;
|
2004-11-11 06:18:09 -05:00
|
|
|
short wc;
|
2001-03-01 23:58:53 -05:00
|
|
|
|
2012-07-29 11:45:29 -04:00
|
|
|
if (TIFFFieldWriteCount(fip) == TIFF_VARIABLE)
|
2004-12-25 15:17:00 -05:00
|
|
|
wc = atoi(argv[arg_index++]);
|
2004-11-11 06:18:09 -05:00
|
|
|
else
|
2012-07-29 11:45:29 -04:00
|
|
|
wc = TIFFFieldWriteCount(fip);
|
2004-06-05 05:05:26 -04:00
|
|
|
|
2004-11-11 06:18:09 -05:00
|
|
|
if (argc - arg_index < wc) {
|
2004-06-05 05:05:26 -04:00
|
|
|
fprintf( stderr,
|
2004-11-11 06:18:09 -05:00
|
|
|
"Number of tag values is not enough. "
|
|
|
|
"Expected %d values for %s tag, got %d\n",
|
2012-07-29 11:45:29 -04:00
|
|
|
wc, TIFFFieldName(fip), argc - arg_index);
|
2020-03-07 10:28:27 -05:00
|
|
|
return EXIT_FAILURE;
|
2004-06-05 05:05:26 -04:00
|
|
|
}
|
|
|
|
|
2017-10-01 13:38:12 -04:00
|
|
|
if (wc > 1 || TIFFFieldWriteCount(fip) == TIFF_VARIABLE) {
|
2004-11-11 06:18:09 -05:00
|
|
|
int i, size;
|
|
|
|
void *array;
|
2004-06-05 05:05:26 -04:00
|
|
|
|
2012-07-29 11:45:29 -04:00
|
|
|
switch (TIFFFieldDataType(fip)) {
|
2004-11-11 06:18:09 -05:00
|
|
|
/*
|
|
|
|
* XXX: We can't use TIFFDataWidth()
|
|
|
|
* to determine the space needed to store
|
|
|
|
* the value. For TIFF_RATIONAL values
|
|
|
|
* TIFFDataWidth() returns 8, but we use 4-byte
|
|
|
|
* float to represent rationals.
|
|
|
|
*/
|
|
|
|
case TIFF_BYTE:
|
|
|
|
case TIFF_ASCII:
|
|
|
|
case TIFF_SBYTE:
|
|
|
|
case TIFF_UNDEFINED:
|
2005-09-13 10:09:10 -04:00
|
|
|
default:
|
2004-11-11 06:18:09 -05:00
|
|
|
size = 1;
|
|
|
|
break;
|
2004-06-05 05:05:26 -04:00
|
|
|
|
2004-11-11 06:18:09 -05:00
|
|
|
case TIFF_SHORT:
|
|
|
|
case TIFF_SSHORT:
|
|
|
|
size = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIFF_LONG:
|
|
|
|
case TIFF_SLONG:
|
|
|
|
case TIFF_FLOAT:
|
|
|
|
case TIFF_IFD:
|
|
|
|
case TIFF_RATIONAL:
|
|
|
|
case TIFF_SRATIONAL:
|
|
|
|
size = 4;
|
|
|
|
break;
|
|
|
|
|
2018-03-07 11:40:23 -05:00
|
|
|
case TIFF_LONG8:
|
|
|
|
case TIFF_SLONG8:
|
|
|
|
case TIFF_IFD8:
|
2004-11-11 06:18:09 -05:00
|
|
|
case TIFF_DOUBLE:
|
|
|
|
size = 8;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
array = _TIFFmalloc(wc * size);
|
|
|
|
if (!array) {
|
|
|
|
fprintf(stderr, "No space for %s tag\n",
|
|
|
|
tagname);
|
2020-03-07 10:28:27 -05:00
|
|
|
return EXIT_FAILURE;
|
2004-11-11 06:18:09 -05:00
|
|
|
}
|
|
|
|
|
2012-07-29 11:45:29 -04:00
|
|
|
switch (TIFFFieldDataType(fip)) {
|
2004-11-11 06:18:09 -05:00
|
|
|
case TIFF_BYTE:
|
|
|
|
for (i = 0; i < wc; i++)
|
|
|
|
((uint8 *)array)[i] = atoi(argv[arg_index+i]);
|
|
|
|
break;
|
|
|
|
case TIFF_SHORT:
|
|
|
|
for (i = 0; i < wc; i++)
|
|
|
|
((uint16 *)array)[i] = atoi(argv[arg_index+i]);
|
|
|
|
break;
|
|
|
|
case TIFF_SBYTE:
|
|
|
|
for (i = 0; i < wc; i++)
|
|
|
|
((int8 *)array)[i] = atoi(argv[arg_index+i]);
|
|
|
|
break;
|
|
|
|
case TIFF_SSHORT:
|
|
|
|
for (i = 0; i < wc; i++)
|
|
|
|
((int16 *)array)[i] = atoi(argv[arg_index+i]);
|
|
|
|
break;
|
|
|
|
case TIFF_LONG:
|
|
|
|
for (i = 0; i < wc; i++)
|
|
|
|
((uint32 *)array)[i] = atol(argv[arg_index+i]);
|
|
|
|
break;
|
|
|
|
case TIFF_SLONG:
|
|
|
|
case TIFF_IFD:
|
|
|
|
for (i = 0; i < wc; i++)
|
2018-03-07 11:40:23 -05:00
|
|
|
((int32 *)array)[i] = atol(argv[arg_index+i]);
|
|
|
|
break;
|
|
|
|
case TIFF_LONG8:
|
|
|
|
for (i = 0; i < wc; i++)
|
|
|
|
((uint64 *)array)[i] = strtoll(argv[arg_index+i], (char **)NULL, 10);
|
|
|
|
break;
|
|
|
|
case TIFF_SLONG8:
|
|
|
|
case TIFF_IFD8:
|
|
|
|
for (i = 0; i < wc; i++)
|
|
|
|
((int64 *)array)[i] = strtoll(argv[arg_index+i], (char **)NULL, 10);
|
2004-11-11 06:18:09 -05:00
|
|
|
break;
|
|
|
|
case TIFF_DOUBLE:
|
|
|
|
for (i = 0; i < wc; i++)
|
|
|
|
((double *)array)[i] = atof(argv[arg_index+i]);
|
|
|
|
break;
|
|
|
|
case TIFF_RATIONAL:
|
|
|
|
case TIFF_SRATIONAL:
|
|
|
|
case TIFF_FLOAT:
|
|
|
|
for (i = 0; i < wc; i++)
|
|
|
|
((float *)array)[i] = (float)atof(argv[arg_index+i]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-06-05 05:05:26 -04:00
|
|
|
|
2012-07-29 11:45:29 -04:00
|
|
|
if (TIFFFieldPassCount(fip)) {
|
|
|
|
ret = TIFFSetField(tiff, TIFFFieldTag(fip),
|
2004-11-11 06:18:09 -05:00
|
|
|
wc, array);
|
2012-07-29 11:45:29 -04:00
|
|
|
} else if (TIFFFieldTag(fip) == TIFFTAG_PAGENUMBER
|
|
|
|
|| TIFFFieldTag(fip) == TIFFTAG_HALFTONEHINTS
|
|
|
|
|| TIFFFieldTag(fip) == TIFFTAG_YCBCRSUBSAMPLING
|
|
|
|
|| TIFFFieldTag(fip) == TIFFTAG_DOTRANGE) {
|
|
|
|
if (TIFFFieldDataType(fip) == TIFF_BYTE) {
|
|
|
|
ret = TIFFSetField(tiff, TIFFFieldTag(fip),
|
2010-07-06 10:30:38 -04:00
|
|
|
((uint8 *)array)[0], ((uint8 *)array)[1]);
|
2012-07-29 11:45:29 -04:00
|
|
|
} else if (TIFFFieldDataType(fip) == TIFF_SHORT) {
|
|
|
|
ret = TIFFSetField(tiff, TIFFFieldTag(fip),
|
2010-07-06 10:30:38 -04:00
|
|
|
((uint16 *)array)[0], ((uint16 *)array)[1]);
|
|
|
|
}
|
|
|
|
} else {
|
2012-07-29 11:45:29 -04:00
|
|
|
ret = TIFFSetField(tiff, TIFFFieldTag(fip),
|
2004-11-11 06:18:09 -05:00
|
|
|
array);
|
|
|
|
}
|
|
|
|
|
|
|
|
_TIFFfree(array);
|
|
|
|
} else {
|
2012-07-29 11:45:29 -04:00
|
|
|
switch (TIFFFieldDataType(fip)) {
|
2004-11-11 06:18:09 -05:00
|
|
|
case TIFF_BYTE:
|
|
|
|
case TIFF_SHORT:
|
|
|
|
case TIFF_SBYTE:
|
|
|
|
case TIFF_SSHORT:
|
2012-07-29 11:45:29 -04:00
|
|
|
ret = TIFFSetField(tiff, TIFFFieldTag(fip),
|
2004-11-11 06:18:09 -05:00
|
|
|
atoi(argv[arg_index++]));
|
|
|
|
break;
|
|
|
|
case TIFF_LONG:
|
|
|
|
case TIFF_SLONG:
|
|
|
|
case TIFF_IFD:
|
2012-07-29 11:45:29 -04:00
|
|
|
ret = TIFFSetField(tiff, TIFFFieldTag(fip),
|
2004-11-11 06:18:09 -05:00
|
|
|
atol(argv[arg_index++]));
|
|
|
|
break;
|
2018-03-07 11:40:23 -05:00
|
|
|
case TIFF_LONG8:
|
|
|
|
case TIFF_SLONG8:
|
|
|
|
case TIFF_IFD8:
|
|
|
|
ret = TIFFSetField(tiff, TIFFFieldTag(fip),
|
|
|
|
strtoll(argv[arg_index++], (char **)NULL, 10));
|
|
|
|
break;
|
2004-11-11 06:18:09 -05:00
|
|
|
case TIFF_DOUBLE:
|
2012-07-29 11:45:29 -04:00
|
|
|
ret = TIFFSetField(tiff, TIFFFieldTag(fip),
|
2004-11-11 06:18:09 -05:00
|
|
|
atof(argv[arg_index++]));
|
|
|
|
break;
|
|
|
|
case TIFF_RATIONAL:
|
|
|
|
case TIFF_SRATIONAL:
|
|
|
|
case TIFF_FLOAT:
|
2012-07-29 11:45:29 -04:00
|
|
|
ret = TIFFSetField(tiff, TIFFFieldTag(fip),
|
2004-11-11 06:18:09 -05:00
|
|
|
(float)atof(argv[arg_index++]));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret != 1)
|
2012-07-29 11:45:29 -04:00
|
|
|
fprintf(stderr, "Failed to set %s\n", TIFFFieldName(fip));
|
2004-11-11 06:18:09 -05:00
|
|
|
arg_index += wc;
|
2001-03-01 23:58:53 -05:00
|
|
|
}
|
2004-11-11 06:18:09 -05:00
|
|
|
} else if (strcmp(argv[arg_index],"-sf") == 0 && arg_index < argc-3) {
|
2001-03-01 23:58:53 -05:00
|
|
|
FILE *fp;
|
2008-01-01 10:46:28 -05:00
|
|
|
const TIFFField *fip;
|
2001-03-01 23:58:53 -05:00
|
|
|
char *text;
|
2008-01-01 10:46:28 -05:00
|
|
|
size_t len;
|
2020-04-05 13:33:02 -04:00
|
|
|
int ret;
|
2001-03-01 23:58:53 -05:00
|
|
|
|
2004-06-05 05:05:26 -04:00
|
|
|
arg_index++;
|
|
|
|
fip = GetField(tiff, argv[arg_index]);
|
|
|
|
|
|
|
|
if (!fip)
|
2020-03-07 10:28:27 -05:00
|
|
|
return EXIT_FAILURE;
|
2001-03-01 23:58:53 -05:00
|
|
|
|
2012-07-29 11:45:29 -04:00
|
|
|
if (TIFFFieldDataType(fip) != TIFF_ASCII) {
|
2004-06-05 05:05:26 -04:00
|
|
|
fprintf( stderr,
|
|
|
|
"Only ASCII tags can be set from file. "
|
2012-07-29 11:45:29 -04:00
|
|
|
"%s is not ASCII tag.\n", TIFFFieldName(fip) );
|
2020-03-07 10:28:27 -05:00
|
|
|
return EXIT_FAILURE;
|
2001-03-01 23:58:53 -05:00
|
|
|
}
|
|
|
|
|
2004-06-05 05:05:26 -04:00
|
|
|
arg_index++;
|
|
|
|
fp = fopen( argv[arg_index], "rt" );
|
2004-11-11 06:18:09 -05:00
|
|
|
if(fp == NULL) {
|
2004-06-05 05:05:26 -04:00
|
|
|
perror( argv[arg_index] );
|
2001-03-01 23:58:53 -05:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2004-05-03 12:39:11 -04:00
|
|
|
text = (char *) malloc(1000000);
|
2020-03-23 12:17:17 -04:00
|
|
|
if(text == NULL) {
|
|
|
|
fprintf( stderr,
|
|
|
|
"Memory allocation error\n");
|
|
|
|
fclose( fp );
|
|
|
|
continue;
|
|
|
|
}
|
2004-05-03 12:39:11 -04:00
|
|
|
len = fread( text, 1, 999999, fp );
|
2001-03-01 23:58:53 -05:00
|
|
|
text[len] = '\0';
|
|
|
|
|
|
|
|
fclose( fp );
|
|
|
|
|
2020-04-05 13:33:02 -04:00
|
|
|
if(TIFFFieldPassCount( fip )) {
|
|
|
|
ret = TIFFSetField( tiff, TIFFFieldTag(fip), (uint16)len, text );
|
|
|
|
} else {
|
|
|
|
ret = TIFFSetField( tiff, TIFFFieldTag(fip), text );
|
|
|
|
}
|
|
|
|
if(!ret) {
|
2004-11-11 06:18:09 -05:00
|
|
|
fprintf(stderr, "Failed to set %s from file %s\n",
|
2012-07-29 11:45:29 -04:00
|
|
|
TIFFFieldName(fip), argv[arg_index]);
|
2001-03-01 23:58:53 -05:00
|
|
|
}
|
2004-06-05 05:05:26 -04:00
|
|
|
|
2004-10-26 14:22:47 -04:00
|
|
|
_TIFFfree( text );
|
2004-06-05 05:05:26 -04:00
|
|
|
arg_index++;
|
2020-03-07 10:28:27 -05:00
|
|
|
} else if (strcmp(argv[arg_index],"-h") == 0 || strcmp(argv[arg_index],"--help") == 0) {
|
|
|
|
usage(EXIT_SUCCESS);
|
2004-11-11 06:18:09 -05:00
|
|
|
} else {
|
|
|
|
fprintf(stderr, "Unrecognised option: %s\n",
|
|
|
|
argv[arg_index]);
|
2020-03-07 10:28:27 -05:00
|
|
|
usage(EXIT_FAILURE);
|
2001-03-01 23:58:53 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-26 13:42:18 -04:00
|
|
|
TIFFRewriteDirectory(tiff);
|
2001-03-01 23:58:53 -05:00
|
|
|
TIFFClose(tiff);
|
2020-03-07 10:28:27 -05:00
|
|
|
return EXIT_SUCCESS;
|
2001-03-01 23:58:53 -05:00
|
|
|
}
|
|
|
|
|
2004-11-11 06:18:09 -05:00
|
|
|
/* vim: set ts=8 sts=8 sw=8 noet: */
|
2010-03-10 13:56:48 -05:00
|
|
|
/*
|
|
|
|
* Local Variables:
|
|
|
|
* mode: c
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* fill-column: 78
|
|
|
|
* End:
|
|
|
|
*/
|