[Image-SIG] Re: Getting Image resolution
Amal P Anand
anandamal@hotmail.com
Sun, 10 Feb 2002 15:00:44 +0530
You can the information from tiff header if the creator
of the image file has specified the resolution.
Below I give a sample program in ANSI C .I have
tried this program on RedHat Linux 6.2;You need a
library called tiffio.h which comes default with Linux;
If you dont have linux i can mail you the complete C
source code or the tiff header specification file;Just
mail me if you want so;Hope this helps you;
Resolution.c
-------------
# include <tiffio.h>
main ( int argc, char * argv [ ] )
{
TIFF * tif = TIFFOpen ( argv [ 1 ], "r" );
if ( tif ) {
uint32 w, h;
uint16 bps, spp;
float xr, yr;
TIFFGetField ( tif, TIFFTAG_IMAGEWIDTH, &w );
TIFFGetField ( tif, TIFFTAG_IMAGELENGTH, &h );
TIFFGetField ( tif, TIFFTAG_BITSPERSAMPLE, &bps );
TIFFGetField ( tif,
TIFFTAG_SAMPLESPERPIXEL, &spp );
TIFFGetField ( tif, TIFFTAG_XRESOLUTION,
&xr );
TIFFGetField ( tif, TIFFTAG_YRESOLUTION,
&yr );
printf("width = %d\nlength = %d\n"
"bitspersample = %d\nsampleperpixel = %d\n"
"xres = %f\nyres = %f\n",w,h,bps,spp,xr,yr);
TIFFClose ( tif );
}
exit ( 0 );
}
-------------------------------------------------------
In linux compile as follows
cc Resolution.c -ltiff
To Run
./a.out your-tiff-file
You can get help about this libtiff library at /usr/doc/libtiff
----- Original Message -----
From: <image-sig-request@python.org>
To: <image-sig@python.org>
Sent: Wednesday, January 30, 2002 10:31 PM
Subject: Image-SIG digest, Vol 1 #557 - 2 msgs
> Send Image-SIG mailing list submissions to
> image-sig@python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.python.org/mailman/listinfo/image-sig
> or, via email, send a message with subject or body 'help' to
> image-sig-request@python.org
>
> You can reach the person managing the list at
> image-sig-admin@python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Image-SIG digest..."
>
>
----------------------------------------------------------------------------
----
> Today's Topics:
>
> 1. Getting Image resolution ? (Doyon, Jean-Francois)
> 2. Re: Getting Image resolution ? (Terry Hancock)
>