libtiff: TIFFGetField returns incorrect image' width and height

171 Views Asked by At

I have a tiff file with 1736x1160x48b resolution. I'm using libtiff 4.0 dll and I have noticed that the resolution being read from the TIFFGetField function is incorrect. I'm getting 156 width and 104 height which is too low.

TIFF* pTiff;
pTiff = dll.OpenTIFF(szFilePath, (char*)("r"));
if (pTiff == nullptr) {
  return LPROCESS_FAILED;
}
uint32_t uWidth = 0;
uint32_t uHeight = 0;
int ret = 0;
ret = dll.TIFFGetField(pTiff, TIFFTAG_IMAGEWIDTH, &uWidth);
ret = dll.TIFFGetField(pTiff, TIFFTAG_IMAGELENGTH, &uHeight );
// ret value is 1 on both lines

Do I need to update my tiff library to 4.5? Is there a fix on the latest version? or is this a format error on the image side? Though when I try to open the image on other photo viewing application, it was able to interpret correctly.

Update: I used libtiff 4.5 latest release and I'm still getting incorrect width and height. My guess is that the image I'm trying to load is not yet fully supported by libtiff. Here is the details of the image from exiftool: enter image description here

0

There are 0 best solutions below