I have a requirement where I have to check the DPI of a bunch of images stored in an oracle database as a blob and make sure they are above 300 dpi. I was planning on reading the field via a c# program and trying to determine their dpi, but i was unsure how to calculate this. Can anyone give me some guidance on how I can determine their DPI.
Asked
Active
Viewed 426 times
0
-
Is this a one-time operation? If not, you'd probably be better off performing the check _before_ inserting the image, and/or storing the dpi in an additional column. DPI is stored differently per image type or even not at all. – C.Evenhuis Nov 17 '17 at 15:30
-
I need to check data that already exists and is stored in the database – Newbie Nov 17 '17 at 15:33
-
You could try fetching these blobs from the database, load them into `System.Drawing.Image.FromStream()` and inspect the `HorizontalResolution` property etc. – C.Evenhuis Nov 17 '17 at 15:42
1 Answers
0
As the name says, DPI represents the number of pixels per inch. To calculate it you need the size of image in inchs and in pixels. The size in inchs is relative to the monitor screen dpi, best resolutions like printers use more points for inch.
So, if your image has 100px and 2in, your dpi is 100/2 = 50 dpi. Realize that the problem is how to determine the size in inchs of your image if basically you need to get an reference of inchs.
Then, would be easier to verify the dpi of image on upload and guarantee the required before the insertion.

Daniel Cruz
- 54
- 1
- 5