akorentlab / leptonica

Automatically exported from code.google.com/p/leptonica
0 stars 0 forks source link

tiffGetCount for buffer #96

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Is there a way how to detect number of pages in tiff encoded buffer with 
leptonica?
Something like tiffGetCount(const l_uint8  *cdata, l_int32  *pn)?

Original issue reported on code.google.com by zde...@gmail.com on 25 May 2014 at 7:54

GoogleCodeExporter commented 9 years ago
Irritating, isn't it?

TIFFReadDirectory() is the only way I know to do the counting.  It would be 
nice if the Tiff functions could take a memory buffer, but ... (you can always 
google the query).

I had to write fopenTiff() just to count the number of files using a file 
stream.  (See my comments there).

Dan

Original comment by dan.bloo...@gmail.com on 26 May 2014 at 12:44

GoogleCodeExporter commented 9 years ago
Well, you can also write it to a tmpfile and read with tiffGetCount(fp, 
&npages):

    fp = tmpfile();
    fwrite(cdata, 1, size, fp);
    rewind(fp);
    tiffGetCount(fp, &npages);

Original comment by dbloomb...@google.com on 29 May 2014 at 8:58