Share via


How can I get Image dpi(dots per inches) ?

Question

Thursday, January 27, 2011 7:38 AM

i develop a account software which is also saving picture and picture size in database(sqlserver 2000) . i want to save picture size in inches so i want to get picture dpi(dpi(dots per inches) to make inches. I am using CommonDialog1 vb6 tool to save picture and get size but now CommonDialog1 doesn't get picture inches size but get picture pixels size so i am calculating inches by pixel

for example, Calculation formula,

Round((Image.Height* / 15*) / 96*, 2)

Detail:

* Image height in Pixels which is getting through CommonDialog1 vb6 tool

*15 is fixed

* 96 is dpi(dots per inches) it isn't fixed

I want to get picture dpi(dots per inches) to make inches.

All replies (9)

Thursday, January 27, 2011 9:11 AM ✅Answered

Faisal,

If you do this kind of programming then first try to inform you what you are doing. 

Wikepedia is a good source for that.

http://en.wikipedia.org/wiki/Dots_per_inch

In my idea a normal image format (for instance bitmap) has no DPI, it is used when printed or displayed

 

Success
Cor


Friday, January 28, 2011 7:31 PM ✅Answered | 2 votes

You can load the image into a Bitmap object (this one is actually the Image property of a PictureBox). That Bitmap object has the numbers you need.

        PictureBox1.ImageLocation = "c:/images/sharpedges.jpg"

        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

 

        Dim dpiX As Single = PictureBox1.Image.HorizontalResolution

        Dim dpiY As Single = PictureBox1.Image.VerticalResolution

 

 


Saturday, January 29, 2011 7:53 AM ✅Answered

The following thread will have ur answer....

http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/314a4e86-6d9b-4e76-8f09-6978f29b9818

 

It all Happenz Sendil


Friday, January 28, 2011 6:34 AM

Thank You for sent the link


Friday, January 28, 2011 2:47 PM

In my idea a normal image format (for instance bitmap) has no DPI, it is used when printed or displayed

 

Success
Cor

Hi Cor,

Interesting thought.

Some image manipulation software such as Paint.Net and famously the well known PhotoShop and others

when resizing an image ( picture ) obviously manage to increase or decrease the numbers of pixels when

 a request to resize the image is called upon.

Obviously an image which is treated as 300dpi will look a lot more grainy than an image that is say 1200dpi

 when printed onto an A4 sheet of paper.

 

Software such as the above can show the image either;

  • Full screen or
  • Actual image size ( where each image pixel is turned into an on screen pixel )

As there are so many different image ( picture ) file formats around these days such as;

  • .bmp or .dib
  • .jpg or .jpeg or .jpe or .jfif
  • .png
  • .gif
  • .tif or .tiff
  • .raw
  • and others

 

Whose to say that some some of those do not actually store some kind of ( "Dots per inch " ) data in their metadata?

Some image files even store the following data;

  • Date and time taken
  • Camera model
  • Shutter speed
  • "f" stop or aperture setting
  • Film speed setting such as ISO400

Get Paint.Net as a FREE download here:>> http://www.paint.net/

or direct via.>> http://www. get **paint.net/
**

 

Regards, John

Click this link to see how to insert a picture into a forum post.


Friday, January 28, 2011 7:15 PM

This forum is not for vb6, it's .Net only. See the forum sticky.

In .Net just call Image.FromFile to load the image, then look at the images HorizontalResolution and VerticalResolution properties.


Saturday, January 29, 2011 7:22 AM

i develop a account software which is also saving picture and picture size in database(sqlserver 2000) . i want to save picture size in inches so i want to get picture dpi(dpi(dots per inches) to make inches. I am using CommonDialog1 vb6 tool to save picture and get size but now CommonDialog1 doesn't get picture inches size but get picture pixels size so i am calculating inches by pixel

for example, Calculation formula,

Round((Image.Height* / 15*) / 96*, 2)

Detail:

* Image height in Pixels which is getting through CommonDialog1 vb6 tool

*15 is fixed

* 96 is dpi(dots per inches) it isn't fixed

I want to get picture dpi(dots per inches) to make inches.


Saturday, January 29, 2011 8:59 PM

...

* 96 is dpi(dots per inches) it isn't fixed

I want to get picture dpi(dots per inches) to make inches.

Hi,

[ImageVariable].HorizontalResolution

[ImageVariable].VerticalResolution

gives you the ppi (Pixels per Inch)

Regards,

  Thorsten


Sunday, January 30, 2011 12:31 AM

Hi Faisal Attari,

You have already asked this question at.>>

http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/571ba03f-b5be-4174-a3ee-85a02becaaa0/

Please do not post the same question more than once.

Regards, John

Click this link to see how to insert a picture into a forum post.