Check image dpi resolution
Moderator: General Moderators
-
elibarnett
- Forum Newbie
- Posts: 2
- Joined: Wed Jan 26, 2005 1:20 pm
Check image dpi resolution
I need to check an uploaded image resolution in dpi, how can I do this in php?
-
elibarnett
- Forum Newbie
- Posts: 2
- Joined: Wed Jan 26, 2005 1:20 pm
basically jpg, maybe gif and png
basically jpg, maybe gif and png
Re: basically jpg, maybe gif and png
According to a quick test I just did using photoshop none of those image formats retain the dpi resolution when saved. I created a file 800*800 pixels square, and 350 DPI. I then saved it in gif, jpg, and png formats. When I opened each of the saved files they all defaulted to 72 dpi..elibarnett wrote:basically jpg, maybe gif and png
So it would appear to be impossible.
Of course all the above image types have a DPI (PPI)....Dots Per Inch/Pixels Per Inch.
You will not be able to get the DPI of an image becuase the figure doesn't really exist. Well, it does, but it is determined by other factors. Lets look at an example.
You take a photo with your digital camera at 2200px X 1700px and this has a resolution of 72dpi.
This would mean the print size of the image is 30" x 23". (2200/72 and 1700/72)
Now, you need to use this image in a magazine and the publisher requires that you provide a 300 DPI image. Not a problem.
Take our original image.
Lets work out the maximum size we can print this image in the magazine.
2200/300 = 7.3
1700/300 = 5.6
which would mean the maximum size you could print this at 300dpi would be 7.2" x 5.6".
Anyway, i have probably gone into too much detail about DPI....but it just illustrates you can work out the DPI using other methods cos DPI isnt really set.
You could work it out from the pixel dimensions and the print size, but i am not sure if PHP can get this information for you.
Mark
You will not be able to get the DPI of an image becuase the figure doesn't really exist. Well, it does, but it is determined by other factors. Lets look at an example.
You take a photo with your digital camera at 2200px X 1700px and this has a resolution of 72dpi.
This would mean the print size of the image is 30" x 23". (2200/72 and 1700/72)
Now, you need to use this image in a magazine and the publisher requires that you provide a 300 DPI image. Not a problem.
Take our original image.
Lets work out the maximum size we can print this image in the magazine.
2200/300 = 7.3
1700/300 = 5.6
which would mean the maximum size you could print this at 300dpi would be 7.2" x 5.6".
Anyway, i have probably gone into too much detail about DPI....but it just illustrates you can work out the DPI using other methods cos DPI isnt really set.
You could work it out from the pixel dimensions and the print size, but i am not sure if PHP can get this information for you.
Mark
The thing it though, if I make a PSD file and set it to 300 DPI, and send it to you, you'll be able to print it and view it exactly as I intended. If I save the same file as a JPG and send it to you then you'll only be able to guess how big I intended it to be.
I assume thats what elibarnett needs to know.. Personally I'd just have a DPI text input box alongside the image upload element.. That'd solve the problem quite nicely.
I assume thats what elibarnett needs to know.. Personally I'd just have a DPI text input box alongside the image upload element.. That'd solve the problem quite nicely.
Not true.onion2k wrote:The thing it though, if I make a PSD file and set it to 300 DPI, and send it to you, you'll be able to print it and view it exactly as I intended. If I save the same file as a JPG and send it to you then you'll only be able to guess how big I intended it to be.
Just tested it right now. Create a new file in PS at 300dpi. Save a JPG, re-open, file is still 300dpi
I tried that last night and it defaulted back to 72. Maybe it depends on your settings. I certainly wouldn't trust every JPG someone uploads to have that sort of information included.Bech100 wrote:Just tested it right now. Create a new file in PS at 300dpi. Save a JPG, re-open, file is still 300dpi
Yeah, it would.AGISB wrote:Somehow the dpi is saved in the jpg but the file is exactly the same size on disk if it is 180 dpi or 96.
Have never noticed that before.
The pixel dimension are exacltly the same no matter what the DPI is (unless you resample).
A 144 x 144 pixel image @ 72dpi = 2" x 2" when printed
A 144 x 144 pixel image @ 144dpi = 1" x 1" when printed
Each image is still the same file size
Working out image files sizes from dimensions
No of pixels in length x No of pixels in height = total No of pixels
Total No of pixels x "No of bits per colour" / 8 = total No of bytes
So for example:
2867 (width in pixels) x 2034 (height in pixels) = 583,1478 pixels
583,1478 x (24/8) = 17,494,434 bytes or 17.5 Mb
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
the thing I was saying is there is not native tag for physical dimensions in the JPEG or GIF standards. i.e. It's quite possibly a Photoshop comment/extension.. sadly my Photoshop doesn't want to start today.. I'll do some checking when I get it back up.
edit: okay.. I had another look at the JFIF headers, and I missed it earlier.. the pixel density information is stored at 0Ah and 0Ch in 2 byte chunks each for horizontal and vertical density respectively.
edit: okay.. I had another look at the JFIF headers, and I missed it earlier.. the pixel density information is stored at 0Ah and 0Ch in 2 byte chunks each for horizontal and vertical density respectively.