- 2005.05.28 17:21 "Re: [Tiff] how to convert a JPEG-IN-TIFF file to jpeg file without decomress & compress", by Joris Van Damme
- 2005.06.29 20:21 "[Tiff] copying jpeg tables", by James Carroll
2005.06.29 20:21 "[Tiff] copying jpeg tables", by James Carroll
Hi, I'm trying to do an ultra-fast copy of JPEG compressed TIFF tiles from one file to another...
tiffcp cheats and decodes each tile, then re-encodes it. I'm hoping to minimize the processor time of decoding and re-encoding.
I'm copying all the standard tags, and using ReadRawTile and WriteRawTile to transfer the tiles, but I also have to copy some other stuff... I'm guessing at least the JpegTables
How do I copy the JPEG_TABLES?
Portions of my code below... and tiffdump that shows the tables below that.
Thanks,
-Jim
..... (lots of tags copied)
if (TIFFGetField(tifIn, TIFFTAG_TILEWIDTH, &tileWidth))
{
TIFFSetField(tifOut, TIFFTAG_TILEWIDTH, tileWidth);
}
if (TIFFGetField(tifIn, TIFFTAG_TILELENGTH, &tileLength))
{
TIFFSetField(tifOut, TIFFTAG_TILELENGTH, tileLength);
}
// Copy JPEG Tables
???????????????????????????????????????????????
// For each tile, read raw, and write raw
tdata_t buf;
ttile_t tile;
buf = _TIFFmalloc(TIFFTileSize(tifIn));
for (tile = 0; tile < TIFFNumberOfTiles(tifIn); tile++)
{
tsize_t tileSize = TIFFReadRawTile(tifIn,
tile,
buf, (tsize_t) -1);
TIFFWriteRawTile(tifOut, tile, buf, tileSize);
}
_TIFFfree(buf);
TIFFClose(tifIn);
TIFFClose(tifOut);
tiffdump for the image I'm trying to copy:
vs00523_p4.tif:
Magic: 0x4949 <little-endian> Version: 0x2a
Directory 0: offset 499632 (0x79fb0) next 0 (0)
ImageWidth (256) SHORT (3) 1<1950>
ImageLength (257) SHORT (3) 1<2188>
BitsPerSample (258) SHORT (3) 3<8 8 8>
Compression (259) SHORT (3) 1<7>
Photometric (262) SHORT (3) 1<6>
Orientation (274) SHORT (3) 1<1>
SamplesPerPixel (277) SHORT (3) 1<3>
PlanarConfig (284) SHORT (3) 1<1>
TileWidth (322) SHORT (3) 1<256>
TileLength (323) SHORT (3) 1<256>
TileOffsets (324) LONG (4) 72
<8 1188 7813 20723 38271 53379 59816 60993 62116 70 308 88528 99915 103191 107125 123874 137313 139069 154530 166768 167906 168969 1 70032 173615 192932 ...>
TileByteCounts (325)
LONG (4) 72 <1180 6625 12910 17548 15108 6437 1177 1123 8192 18220 11387 3276 3934 16749 13439 1756 15461 12238 1138 1063 1063 3583 19317 81 35 ...>
347 (0x15b) UNDEFINED (7) 574
<0xff 0xd8 0xff 0xdb 00 0x43 00 0x6 0x4 0x5 0x6 0x5 0x4 0x6 0x6 0x5 0x6 0x7 0x7 0x6 0x8 0xa 0x10 0xa ...>
YCbCrSubsampling (530) SHORT (3) 2<2 2>
ReferenceBlackWhite (532) RATIONAL (5) 6<0 255 128 255 128 255>
the 347 is the tag that shows there are 574 elements in the jpeg tables