GreycLab/CImg

Resolution tiff tags

Closed this issue · 0 comments

I need to set the tiff tags: resolution unit, resolution x, and resolution y.
Looking at the code of save_tiff in CImg.h I see that:

  • TIFFTAG_RESOLUTIONUNIT is always set to RESUNIT_NONE
  • TIFFTAG_XRESOLUTION is set to 1.0f / voxel_size[0]
  • TIFFTAG_YRESOLUTION is set to 1.0f / voxel_size[1],

I define:
const char* img_fname = "Image.tif";
const unsigned int img_compression = 0; //no compression
const float img_voxel_size[] = { 0.02, 0.02, 0.0 }; //resolution x, y = 50 pixels/unit
const char* img_description = "Image Description";

and, after generating the image, I store it with:
img_map.save_tiff(img_fname, img_compression, img_voxel_size, img_description);

The tags I get (with AWare Systems AsTiffTagViewer 2.00) are:
ImageWidth (1 Short): 919
ImageLength (1 Short): 5613
BitsPerSample (1 Short): 16
Compression (1 Short): Uncompressed
Photometric (1 Short): MinIsBlack
FillOrder (1 Short): Msb2Lsb
ImageDescription (18 ASCII): Image Description
StripOffsets (1404 Long): 16, 7368, 14720, 22072, 29424, 36776, 44128,...
Orientation (1 Short): TopLeft
SamplesPerPixel (1 Short): 1
RowsPerStrip (1 Short): 4
StripByteCounts (1404 Long): 7352, 7352, 7352, 7352, 7352, 7352, 7352,...
XResolution (1 Rational): 50
0 (0 NoType):
1 (10328190 NoType):
1 (1 NoType):
1 (1 NoType):
5 (10328198 NoType):

so XResolution is OK, but then, it seems to be some kind of memory error.

My questions are:

  1. Could it be a bug, or am I doing anything wrong?
  2. Would it be possible to give more flexibility to save_tiff and to allow it to set some other tags (as with libtiff), as: RESOLUTIONUNIT, ORIENTATION, and PHOTOMETRIC?