int main(int argc,char *argv[]) { char *fname="newtif.tif"; int flags; TIFF *tif=(TIFF*)0; /* TIFF-level descriptor */ if (argc>1) fname=argv[1]; tif=TIFFOpen(fname,"r"); if (!tif) goto failure; /* We want the double array listed */ //flags = TIFFPRINT_MYMULTIDOUBLES; flags = 0; TIFFPrintDirectory(tif,stdout,flags); TIFFClose(tif); exit (0); failure: printf("failure in listtif\n"); if (tif) TIFFClose(tif); exit (-1); }
int vglPrintTiffInfo(char* inFilename, char* msg){ if (msg){ printf("====== %s:\n", msg); } else { printf("====== vglPrintTiffInfo:\n"); } TIFF* tif = TIFFOpen(inFilename, "r"); if (tif == NULL){ fprintf(stderr, "%s:%s: Error: File %s not found.\n", __FILE__, __FUNCTION__, inFilename); return 1; } if (tif) { uint32 w, h; uint16 bps, spp, photo, config, pageNumber, numberPages; uint32 subfileType; tdir_t dirCount; tstrip_t stripMax; tstrip_t istrip; tsize_t stripSize; tsize_t npixels; tsize_t pixelSize; tdata_t raster; tsize_t result, offset; char* rasterc; uint32 iw, ih; int i; do{ TIFFPrintDirectory(tif, stdout, 255); } while(TIFFReadDirectory(tif)); printf("TIFFScanlineSize = %ld\n", (long int) TIFFScanlineSize(tif)); printf("TIFFRasterScanlineSize = %ld\n", (long int) TIFFRasterScanlineSize(tif)); printf("TIFFStripSize = %ld\n", (long int) TIFFStripSize(tif)); printf("TIFFNumberOfStrips = %d\n", TIFFNumberOfStrips(tif)); printf("TIFFVStripSize = %ld\n", (long int) TIFFVStripSize(tif,0)); printf("TIFFTileRowSize = %ld\n", (long int) TIFFTileRowSize(tif)); printf("TIFFTileSize = %ld\n", (long int) TIFFTileSize(tif)); printf("TIFFNumberOfTiles = %d\n", TIFFNumberOfTiles(tif)); printf("TIFFVTileSize = %ld\n", (long int) TIFFVTileSize(tif,0)); printf("TIFFDefaultStripSize = %d\n", TIFFDefaultStripSize(tif,0)); printf("TIFFFileno = %d\n", TIFFFileno(tif)); printf("TIFFGetMode = %d\n", TIFFGetMode(tif)); printf("TIFFIsTiled = %d\n", TIFFIsTiled(tif)); printf("TIFFIsByteSwapped = %d\n", TIFFIsByteSwapped(tif)); printf("TIFFRGBAImageOK = %d\n", TIFFRGBAImageOK(tif, (char*)"TIFFRGBAImageOK mesg\n")); TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bps); TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &spp); TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photo); TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &config); TIFFGetField(tif, TIFFTAG_PAGENUMBER, &pageNumber, &numberPages); TIFFGetField(tif, TIFFTAG_SUBFILETYPE, &subfileType); stripSize = TIFFStripSize(tif); stripMax = TIFFNumberOfStrips(tif); switch(bps){ case 8: pixelSize = 1; break; case 16: pixelSize = 2; break; default: pixelSize = 0; break; } dirCount = tif_DirCount(tif); printf("size = %lu, w = %d, h = %d, spp = %d, bps = %d, pixelSize = %ld\n", sizeof(w), w, h, spp, bps, (long int) pixelSize); printf("Page Number = %d\n", pageNumber); printf("Number Pages = %d\n", numberPages); printf("Photometric interpretation = %d\n", photo); printf("Planar configuration = %d\n", config); printf("stripSize = %ld, stripMax = %d\n", (long int) stripSize, stripMax); printf("Number of directories = %d\n", dirCount); printf("Subfile type = %d\n", subfileType); //printbin((char*)&w, sizeof(w)); //printbin((char*)&h, sizeof(h)); //raster = tif_ReadData(tif); //tif_PrintAsc(tif, raster, (char*)"ascimg.txt"); TIFFClose(tif); } return 0; }