• Post Reply Bookmark Topic Watch Topic
  • New Topic

DPI of an image?  RSS feed

 
Sid Dixon
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
How can I find the DPI of an image?
The following code tells me the size of the image in pixels which I want to convert to millimetres.
When I have looked at conversions I can find - "mm = (pixels * 25.4) / dpi" but how do I find out the DPI?

 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The DPI (dots-per-inch) is not an intrinsic property of images. However, in many image formats you can store the DPI resolution in the image file as metadata.

You can get the metadata from an image file using the ImageIO API. I've found an example here that shows how to read the metadata of an image file. You can try it out and see if the DPI is in the metadata of the JPG file you are using.
 
Carey Brown
Saloon Keeper
Posts: 3314
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to peek at your file's meta data there's a great command line program (free) called "exiftool" which also has a GUI companion program "exiftoolgui". The information you want shows up as: XResolution, YResolution, and ResolutionUnit. Note that what you are looking for is more accurately referred to as PPI (pixels per inch). DPI (dots per inch) is reserved for things like ink jet printers that use a number of ink "dots" to create the color perceived for a single pixel.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:Note that what you are looking for is more accurately referred to as PPI (pixels per inch).

Yes, but it's a display resolution; it has nothing whatsoever to do with an image; so I'd be very surprised if it's actually available, except maybe as a "1:1" guideline. A JPEG image has a resolution, or a height x width (in pixels); not a "size".

But I could be wrong. What I don't know about rendering would fill the British Museum.

Winston
 
Carey Brown
Saloon Keeper
Posts: 3314
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Per Wikipedia (search "image resolution"):
The term resolution is often used for a pixel count in digital imaging, even though American, Japanese, and international standards specify that it should not be so used, at least in the digital camera field.

So, the image width x height in pixels is appropriately referred to as "size", not "resolution".

Resolution is almost entirely ignored by today's software and only comes into play (if that) for specific printing purposes. PPI for display resolution was originally based on the Mac's screen resolution of 72 PPI; with today's monitors having so many different resolutions and physical dimensions using "resolution" for display is pretty pointless.

At this point I would toss this back to the original poster to ask him to what end does he need to come up with an images resolution?
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:So, the image width x height in pixels is appropriately referred to as "size", not "resolution".

So there you go you see: dinosaur strikes out again.

However, I would still presume that anything (like "DPI") that refers to "inches" can be taken with a huge grain of salt.

Winston
 
Sid Dixon
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the comments.
I do work in the printing industry and am looking at resolution to print large format posters.
Clients send images which can be any resolution (72 dpi to 300 dpi). Depending on size of original image it will affect if image will print clearly at an enlarged size.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sid Dixon wrote:I do work in the printing industry and am looking at resolution to print large format posters.
Clients send images which can be any resolution (72 dpi to 300 dpi). Depending on size of original image it will affect if image will print clearly at an enlarged size.

Really? Size (ie, total pixels) I can understand, but I would have thought that, let's say, a 12 megapixel image would be less likely to enlarge well if it's original "resolution" was 300 DPI than if it was 72 - or certainly no better - which seems bass-ackwards to me.

But maybe you can explain. Like I say, I'm no expert on this stuff.

Winston
 
Carey Brown
Saloon Keeper
Posts: 3314
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sid Dixon wrote:I do work in the printing industry and am looking at resolution to print large format posters.
Clients send images which can be any resolution (72 dpi to 300 dpi). Depending on size of original image it will affect if image will print clearly at an enlarged size.

In your case you want to ignore any stored resolution and calculate your own based on the pixel dimensions and the final size of your printed poster. Note that the stored resolution is often set to some arbitrary values depending on the camera manufacturer, often 240 or 300 PPI, but sometimes 72 PPI, and sometimes missing all together.

Example:
(Assuming original photo and poster have the same aspect ratio and orientation and that you intend to scale the photo to fill the poster)
A photo with a width of 4,000 pixels and a poster with a width of 20 inches would give you a resolution of: 200 PPI. This should be adequate because you don't usually look at a poster from very close up.

Edit:
Google "digital photo printing resolutions". There's lots of info on this topic with suggested PPI for a given print size. Also Photoshop allows me to set the resolution to anything I want which has no effect on whether or not I have enough pixels for a given print size.
 
Felipe Rego Pinto
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sid Dixon wrote:Thanks for the comments.
I do work in the printing industry and am looking at resolution to print large format posters.
Clients send images which can be any resolution (72 dpi to 300 dpi). Depending on size of original image it will affect if image will print clearly at an enlarged size.


Greetings,

Here are my suggestion:

1 - Ask in your work for the minimal DPI to print.
2 - Ask your client for the print size in inches (height and width).

Your program should calculate:

(print height) * (minimal DPI) <= original image height in pixels?
(print width) * (minimal DPI) <= original image width in pixels?

If both sentences are true, the image is ok!

Best regards,
Felipe
 
Sid Dixon
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your comments guys.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!