How to read DPI of local image/bitmap?
...when user "uploads" image via FileReference.
How to read DPI of local image/bitmap?
...when user "uploads" image via FileReference.
Assuming your image even has a DPI value encoded in it the value is meaningless. I could make a 64px x 64px image that has it's DPI value set to 300, it would still not be a good candidate for printing. This article goes into greater detail.
What you should do instead is determine what DPI value you will print images at (usually this is 300 DPI) then calculate the value based on the pixel dimensions of the image. Here's one way to calculate print size based on source image size.
Forget about embeded DPI, take the image pixel size and calculate how large (in inches) is it at 300 DPI (which is the minimum density you need to print something clear on paper, however, for banners and large size prints it could be 180 or even 72 DPI). If the user tries to print the image on a larger sheet of paper that the resulting size, pop a warning.