Link to home
Start Free TrialLog in
Avatar of ulf_k
ulf_k

asked on

Determine the DPI of a tiff image

Hi everybody,
is it possible to get the dpi resolution of a tiff image in php?
I know there's a php extension for imagemagick but this means to recompile php.
I think thats a huge effort for only wanting to know the dpi resolution of an image.

Thanks for any suggestion.
Greetings, -ulf-
Avatar of inq123
inq123

Hi ulf_k,

What do you mean by "DPI resolution"?  I thought DPI only applies to printers?

If you want to know the dimension of the image, use getimagesize().  It even returns color depth.  Here's what it returns (quoted from php documentation):

"Returns an array with 4 elements. Index 0 contains the width of the image in pixels. Index 1 contains the height. Index 2 is a flag indicating the type of the image: 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF. These values correspond to the IMAGETYPE constants that were added in PHP 4.3. Index 3 is a text string with the correct height="yyy" width="xxx" string that can be used directly in an IMG tag.

With JPG images, two extra indexes are returned: channels and bits. channels will be 3 for RGB pictures and 4 for CMYK pictures. bits is the number of bits for each color.

Beginning with PHP 4.3, bits and channels are present for other image types, too."


Cheers!
Avatar of ulf_k

ASKER

Hi,
I know getimagesize() and it's output.
But TIFF images also store the resolution in DPI in their header. Thats what i want to retrieve.

-ulf-
ASKER CERTIFIED SOLUTION
Avatar of inq123
inq123

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ulf_k

ASKER

Great, this worked.
Many thanks for this solution!!
Greetings, -ulf-
Glad that I could help!