[PHP] Re: How does one obtain the resolution of an image in PHP?

2006-03-17 Thread Barry

Simon M. Campden-Main wrote:

Good morning, folks.

Can any one direct me to a snippet or suggest an approach to obtaining the
resolution of an image [file] with PHP.  exif_read_data() is great if the 
image
was taken with a camera that is exif compliant, but is no help with my 
scanned

images.  getimagesize() gives me height and width - not much help that I can
see. I want ppi!  I've no doubt that this is another case where the answer 
is

painfully obvious and my mind to dull, but I've spent the better part of the
day searching usenet groups and the PHP docs and come up with naught.
I'm running the current Cent OS distribution of EL, PHP Version 4.3.9 with, 
of

course, GD support. Any suggestions would be most appreciated.
Thank you.
Simon
[EMAIL PROTECTED]

 

There is no way you can do it.
To have on screen e.g. 40 ppi or 80 ppi when the image has a size of 
400x400 pixel you would have to read out the image how big a pixel in it is.
at 80 ppi you would have your normal image and on 40 ppi the pixels used 
per dot would be duplicated. you still have 400 pixel in width and you 
would not be able to count the pixels who got duplicated.


If you are lucky it's written in the file. Otherwise no chance.

The normal screen resolution is: with an average of 0.26 mm ~ 3.8 
pixel/mm ~ 97 pixel per inch.

No matter what kind of resolution you would choose
(800x600,1024x768 etc.)

an image having for example 48ppi would have pixels that use 2x2 pixels 
(4 pixels) as one colored pixel and so on.


Now guess what you see when you have 194 ppi.
Nothing, it's still 97 ppi because it's not possible for the screen to 
view anything else. Normally the screen would just duplicate the 
imagesize from 400x400 to 800x800.


Greets Barry

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: How does one obtain the resolution of an image in PHP?

2006-03-17 Thread - Edwin -
Hi!

On Fri, 17 Mar 2006 09:46:16 +0100
Barry wrote:

 Simon M. Campden-Main wrote:
  Good morning, folks.
  
  Can any one direct me to a snippet or suggest an approach
  to obtaining the resolution of an image [file] with PHP.
  [ . . . ]
 
 There is no way you can do it.
 To have on screen e.g. 40 ppi or 80 ppi when the image has a
 size of 400x400 pixel you would have to read out the image
 how big a pixel in it is. at 80 ppi you would have your
 normal image and on 40 ppi the pixels used per dot would be
 duplicated. you still have 400 pixel in width and you would
 not be able to count the pixels who got duplicated.
 
 If you are lucky it's written in the file. Otherwise no
 chance.
 
 The normal screen resolution is: with an average of 0.26 mm ~
 3.8 pixel/mm ~ 97 pixel per inch.
 No matter what kind of resolution you would choose
 (800x600,1024x768 etc.)

Reading the surrounding sentences, I think I can see where
you're coming from. But, the above statement is a bit
confusing.

There is a reason why it's called pixel per INCH. And it
definitely have something to do whether your monitor
is set to 800x600, 1024x768, etc.

A 15-inch monitor at 800x600 will have around 53ppi x 40ppi
(800 pixels divided by 15 inches, etc.) and *the same* monitor
at 1024x768 will have around 68ppi x 51ppi.

If your 15' monitor is normally setup at 1024x768, everything
(images, etc.) will look a bigger if the same image is viewed
using the same monitor at 800x600. This happens because
the pixels are now bigger. (One image pixel is now compose
of many physical dots on the screen.) But, I guess, you already
knew that. (^_^)

 an image having for example 48ppi would have pixels that use
 2x2 pixels (4 pixels) as one colored pixel and so on.
 
 Now guess what you see when you have 194 ppi.
 Nothing, it's still 97 ppi because it's not possible for the
 screen to view anything else. Normally the screen would just
 duplicate the imagesize from 400x400 to 800x800.
 
 Greets Barry
 

HTH  HAND,

- Edwin -

-- 
He that is slow to anger is abundant in discernment, but
 one that is impatient is exalting foolishness. - Proverbs 14:29

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php