2021.02.14 10:16 "[Tiff] Maximum count of characters can write to tag", by Andriy Marchak

2021.02.14 14:58 "Re: [Tiff] Maximum count of characters can write to tag", by Roger Leigh

I'm trying to add more than 1 million characters to the <ImageDescription> tag using:

tiffset -sf 270 PATH\test.txt PATH\test_image.tif

As a result, I had 1 million characters in this tag. So, there is a limit of 1 million characters for writing to tags using LibTIFF, right? How did I understand that isn't a limit of the tag's field? I can write to this tag about 50 million characters using ExifTool, for example. But ExifTool doesn't support writing for BigTIFF. So, I have a question: is there a possibility to increase the count of characters for LibTIFF? Can you consider this thing, please?

It’s not a libtiff limitation. But it is a bug in the “tiffset” tool:

text = (char *) malloc(1000000);
if(text == NULL) {
    fprintf( stderr,
             "Memory allocation error\n");
    fclose( fp );
    continue;
}
len = fread( text, 1, 999999, fp );
text[len] = '\0';

I have no idea what the justification is for that arbitrary restriction, but that’s why you’re seeing the behaviour.

There’s also a limitation in the LibTIFF API for TIFFSetField here as well. It requires the entire text content to be buffered in memory. It would be nice if you could stream the data from the source file and append to the TIFF file, then use that file range as the input value for TIFFSetField; all it would need to do is update the size and offset in the IFD. That would also be potentially useful for reading as well, so you can just stream the range from the TIFF and process it however you need to.

Issue opened here: https://gitlab.com/libtiff/libtiff/-/issues/241

Regards,

Roger