TIFF and LibTiff Mail List Archive


2014.06.17 09:46 "[Tiff] In-memory tiffs", by Benedikt_Führer
2014.06.17 13:25 "Re: [Tiff] In-memory tiffs", by Bob Friesenhahn
2014.06.19 21:48 "Re: [Tiff] In-memory tiffs", by Olivier Paquet
2014.06.20 13:23 "Re: [Tiff] In-memory tiffs", by Benedikt_Führer
2014.06.20 17:29 "Re: [Tiff] In-memory tiffs", by Olivier Paquet

2014.06.20 13:23 "Re: [Tiff] In-memory tiffs", by Benedikt_Führer

Hey Olivier,

yes, you're completely right. I've also tracked it down thus far by myself already.

I finally succeeded in compiling libtiff with debug information (just had to add the according compiler flag in a make config file) and can now step through the source - really helpful.

I've also tried using a stringstream already but the same problem still persists: When trying to write a 2nd directory, libtiff tries to read the first directory from the stream. Now as you said, the ostringstream interface doesn't support reading. However, even if I'm using a stringstream which inherits both, istream and ostream, I'm still forced to interpret it as either one when passing the pointer to TIFFStreamOpen. Interpreting it as an istream doesn't make any sense at that point because libtiff will then try to read an existing tiff image from memory and fail when it can't read a tiff header from the empty stream. So I'm still forced to adhere to the ostream interface which still doesn't support reading (_tiffosRead contains of only one statement: return 0).

And that I find, is somewhat strange because I doubt I'm the first person who wants to use it like that. How was this supposed to be done then?

Gesendet: Donnerstag, 19. Juni 2014 um 23:48 Uhr
Von: "Olivier Paquet" <>
An: "Benedikt Führer" <>
Cc: "TIFF mailing list" <>
Betreff: Re: [Tiff] In-memory tiffs

2014-06-17 5:46 GMT-04:00 "Benedikt Führer" <>:

> 1) I'm using the helper functions TIFFStreamOpen to try to write multi-directory tiffs into an ostringstream in binary mode. It works perfectly fine for the first directory but as soon as I call TIFFWriteDirectory the 2nd time, it will fail with the error message "Couldn't fetch directory count". What am I doing wrong here? I

I haven't use those in a long time but I think ostringstream is write-only. The only thing you can read is the completed "string". You should probably use a stringstream instead so you can both read and write. I'm fairly certain libtiff needs to be able to read back data it has previously written to a file.