Created
December 10, 2022 12:40
-
-
Save jcupitt/912b0da1c95b615152fa0fbd6e4cc821 to your computer and use it in GitHub Desktop.
make a multipage tiff file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* compile with | |
* | |
* gcc -Wall createtiff.c `pkg-config libtiff --cflags --libs` | |
*/ | |
#include <tiffio.h> | |
int | |
main (int argc, const char **argv) | |
{ | |
TIFF *tiff; | |
if (!(tiff = TIFFOpen(argv[1], "w"))) | |
return 1; | |
for (int i = 0; i < 10; i++) { | |
char pixel[1] = { 128 }; | |
TIFFSetField (tiff, TIFFTAG_IMAGEWIDTH, 1); | |
TIFFSetField (tiff, TIFFTAG_IMAGELENGTH, 1); | |
TIFFSetField (tiff, TIFFTAG_SAMPLESPERPIXEL, 1); | |
TIFFSetField (tiff, TIFFTAG_BITSPERSAMPLE, 8); | |
TIFFSetField (tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); | |
if (TIFFWriteScanline(tiff, pixel, 0, 0) < 0) | |
return 1; | |
if (!TIFFWriteDirectory(tiff)) | |
return 1; | |
} | |
TIFFClose (tiff); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment