diff options
author | Matt Bosworth <mbosworth@neuropace.com> | 2016-01-19 15:42:31 -0800 |
---|---|---|
committer | Matt Bosworth <mbosworth@neuropace.com> | 2016-01-22 12:52:50 -0800 |
commit | 4e53ed79929e4f0d9654ccd8c557fd38cda9d846 (patch) | |
tree | c772f4bb34080b7c6633f8419e15b35317cab568 /src/gd_tiff.c | |
parent | 6913dd3cd2a7c2914ad9622419f9343bfe956135 (diff) | |
download | libgd-4e53ed79929e4f0d9654ccd8c557fd38cda9d846.tar.gz |
Added support for reading and writing TIFFTAG_XRESOLUTION and
TIFFTAG_YRESOLUTION. Includes a unit test.
Diffstat (limited to 'src/gd_tiff.c')
-rw-r--r-- | src/gd_tiff.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/gd_tiff.c b/src/gd_tiff.c index 9da2595..0211f71 100644 --- a/src/gd_tiff.c +++ b/src/gd_tiff.c @@ -282,6 +282,9 @@ void tiffWriter(gdImagePtr image, gdIOCtx *out, int bitDepth) bitsPerSample = (bitDepth == 24 || bitDepth == 8) ? 8 : 1; TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, bitsPerSample); + TIFFSetField(tiff, TIFFTAG_XRESOLUTION, (float)image->res_x); + TIFFSetField(tiff, TIFFTAG_YRESOLUTION, (float)image->res_y); + /* build the color map for 8 bit images */ if(bitDepth != 24) { colorMapRed = (uint16 *) gdMalloc(3 * (1 << bitsPerSample)); @@ -795,6 +798,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile) char save_transparent; int image_type; int ret; + float res_float; gdImagePtr im = NULL; @@ -957,7 +961,14 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile) goto error; } - if (TIFFGetField (tif, TIFFTAG_ORIENTATION, &orientation)) { + if (TIFFGetField(tif, TIFFTAG_XRESOLUTION, &res_float)) { + im->res_x = (unsigned int)res_float; //truncate + } + if (TIFFGetField(tif, TIFFTAG_YRESOLUTION, &res_float)) { + im->res_y = (unsigned int)res_float; //truncate + } + + if (TIFFGetField(tif, TIFFTAG_ORIENTATION, &orientation)) { switch (orientation) { case ORIENTATION_TOPLEFT: case ORIENTATION_TOPRIGHT: |