[Gdal-dev] About image resolution

Andrey Kiselev dron at ak4719.spb.edu
Tue Apr 20 03:23:01 EDT 2004


On Tue, Apr 20, 2004 at 02:25:54PM +0800, xqcheng wrote:
>    Image resolution I cared about is not the value returned by
>    GDALGetGeoTransform() Since    Most images doesn't contain Geo
>    information. For tiff images, I want to get value of tag
>    XResolution, YResolution,How can I do that with GDAL? I am working
>    for a Digital photogrammetry company. When photo has been scanned,
>    scanning resolution is very important! So that is why I want to get
>    raw resolution of a pixel(no relation with Geo info)

For TIFF files you will get resolution in the metadata records
TIFFTAG_XRESOLUTION, TIFFTAG_YRESOLUTION and TIFFTAG_RESOLUTIONUNIT. You
should use something like:

    hDataset = GDALOpen( pszFilename, GA_ReadOnly );
    papszMetadata = GDALGetMetadata( hDataset, NULL );
    if(CSLCount(papszMetadata) > 0)
    {
	const char *pszXRes, *pszYRes, *pszResUnit;
        int iXRes, iYRes;

        pszXRes = CSLFetchNameValue(papszMetadata, "TIFFTAG_XRESOLUTION");
	iXRes = atoi(pszXRes);
	pszYRes = CSLFetchNameValue(papszMetadata, "TIFFTAG_YRESOLUTION");
	iYRes = atoi(pszYRes);


	/* Units: 1 - none, 2 - inches, 3 - centimeters. */
	pszResUnit = CSLFetchNameValue(papszMetadata, "TIFFTAG_RESOLUTIONUNIT");
    }

						Andrey

-- 
Andrey V. Kiselev
Home phone:  +7 812 5274898  ICQ# 26871517



More information about the Gdal-dev mailing list