Discussion:
How to find/read resolution values of TIFF image file
muthu kumar
2006-08-25 05:40:35 UTC
Permalink
Dear Friends,

I am new to Tiff file processing.
I can read the tiff file and i used the functions to
assign the resolution of the image as follows,

uint32 w,h,bpp, xres=0, yres=0, resunit=2;

TIFFSetField(tiff,TIFFTAG_RESOLUTIONUNIT,(uint16)resunit);
TIFFSetField(tiff,TIFFTAG_XRESOLUTION,(float)xres);
TIFFSetField(tiff,TIFFTAG_YRESOLUTION,(float)yres);

and it works well. But when i tried to read the
resolution using the functions

uint32 w,h,bpp,xres=0, yres=0, resunit=0;

TIFFGetField(tiff, TIFFTAG_XRESOLUTION, &xres);
TIFFGetField(tiff, TIFFTAG_YRESOLUTION, &yres);
TIFFGetField(tiff, TIFFTAG_RESOLUTIONUNIT, &resunit);

I got the results like
xres = 0x42900000 or xres = 0x43960000

I know that the
xres = 0x42900000 for dpi = 72
and xres = 0x43960000 for dpi = 300

But I want to know how to calculate the dpi values
from this hex values. Is there any fomula for this.
Or the function i am using is wrong.

Please help.

Thankyou.

Muthu.J
***@yahoo.com

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Tiff mailing list: ***@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Toby Thain
2006-08-25 05:56:38 UTC
Permalink
Post by muthu kumar
Dear Friends,
I am new to Tiff file processing.
I can read the tiff file and i used the functions to
assign the resolution of the image as follows,
uint32 w,h,bpp, xres=0, yres=0, resunit=2;
TIFFSetField(tiff,TIFFTAG_RESOLUTIONUNIT,(uint16)resunit);
TIFFSetField(tiff,TIFFTAG_XRESOLUTION,(float)xres);
TIFFSetField(tiff,TIFFTAG_YRESOLUTION,(float)yres);
and it works well. But when i tried to read the
resolution using the functions
uint32 w,h,bpp,xres=0, yres=0, resunit=0;
TIFFGetField(tiff, TIFFTAG_XRESOLUTION, &xres);
TIFFGetField(tiff, TIFFTAG_YRESOLUTION, &yres);
TIFFGetField(tiff, TIFFTAG_RESOLUTIONUNIT, &resunit);
I got the results like
xres = 0x42900000 or xres = 0x43960000
I know that the
xres = 0x42900000 for dpi = 72
and xres = 0x43960000 for dpi = 300
But I want to know how to calculate the dpi values
from this hex values. Is there any fomula for this.
Or the function i am using is wrong.
If xres and yres are defined as 'float' type, you should see what you
expect.

--Toby
Post by muthu kumar
Please help.
Thankyou.
Muthu.J
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
_______________________________________________
Tiff mailing list: ***@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
muthu kumar
2006-08-29 14:02:13 UTC
Permalink
Yes, after changing into proper data type (float,
uint16, uint32) for the variables, now I can
read/write the proper values.

After your mail i saw this site and it gives the
proper data type for the variables.

http://www.devdaily.com/unix/man/man3/TIFFGetField.3t.shtml

Thank you very much.

-- Muthukumar. J
Post by muthu kumar
Post by muthu kumar
Dear Friends,
I am new to Tiff file processing.
I can read the tiff file and i used the functions
to
Post by muthu kumar
assign the resolution of the image as follows,
uint32 w,h,bpp, xres=0, yres=0, resunit=2;
TIFFSetField(tiff,TIFFTAG_RESOLUTIONUNIT,(uint16)resunit);
Post by muthu kumar
TIFFSetField(tiff,TIFFTAG_XRESOLUTION,(float)xres);
TIFFSetField(tiff,TIFFTAG_YRESOLUTION,(float)yres);
Post by muthu kumar
and it works well. But when i tried to read the
resolution using the functions
uint32 w,h,bpp,xres=0, yres=0, resunit=0;
TIFFGetField(tiff, TIFFTAG_XRESOLUTION, &xres);
TIFFGetField(tiff, TIFFTAG_YRESOLUTION, &yres);
TIFFGetField(tiff, TIFFTAG_RESOLUTIONUNIT,
&resunit);
Post by muthu kumar
I got the results like
xres = 0x42900000 or xres = 0x43960000
I know that the
xres = 0x42900000 for dpi = 72
and xres = 0x43960000 for dpi = 300
But I want to know how to calculate the dpi values
from this hex values. Is there any fomula for
this.
Post by muthu kumar
Or the function i am using is wrong.
If xres and yres are defined as 'float' type, you
should see what you
expect.
--Toby
Post by muthu kumar
Please help.
Thankyou.
Muthu.J
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam
protection around
Post by muthu kumar
http://mail.yahoo.com
_______________________________________________
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Tiff mailing list: ***@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Joris
2006-08-29 15:32:44 UTC
Permalink
Muthu,
Post by muthu kumar
http://www.devdaily.com/unix/man/man3/TIFFGetField.3t.shtml
The word for the disease of which your link is a symptom, is 'diaspora',
I think. There are hundreds of copies of the man pages everywhere, most
of them very outdated, while most misleadingly seem up to date... If we
want to convince people there's LibTiff beyond version 2.x.x, we'll
have to wait a decade for the average version number out there to
advance that much...

No, it's worse, there's also that hijacked site whose URL and presence
in all old-timer's bookmarks strongly suggests it is the official one,
as in fact it once was...

It's also a bit ironical that people are actually making money of such
copies, putting up Google and other ads on those pages, while actual
LibTiff, the actual tree that cannot be found surrounded as it is by a
vast forest of outdated snapshots, often doesn't advance as much as it
could due to lack of funds.

So please be aware that the official website of LibTiff is
http://www.remotesensing.org/libtiff/. The man pages are at
http://www.remotesensing.org/libtiff/man/index.html. So the single
official copy of the TIFFGetField man page is
http://www.remotesensing.org/libtiff/man/TIFFGetField.3tiff.html.


Best regards,

Joris Van Damme
***@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html

_______________________________________________
Tiff mailing list: ***@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/

Continue reading on narkive:
Loading...