Solution 1 :
How to get image dimension in inches without knowing the DPI?
The question doesn’t make much sense.
In general, a digital image has no inherent size in inches, or an inherent DPI (dots per inch). It has a size in pixels (or dots).
The DPI is actually a property of the device you are displaying the image on. For an image that is displayed, you multiply the DPI of the device by the number of pixels in the height or width of the image to give you the height / width of the image on the screen. (If the image has been scaled, the scaling factor needs to be taken into account too.)
In the case of images produced by digital cameras, the metadata of the image may include a “resolution height DPI” and “resolution width DPI”. I couldn’t find a explanation of what these are supposed to mean, but I surmise that they are either
- the physical resolution of the capture device (e.g. CCD), or
- a value chosen by the creator of the image to give you their preferred image size.
Neither of these is of much relevance when you are displaying an image. (IMO)
Problem :
I am new in android studio… I was searching as to how i can convert the dimensions of an image. I found out that you need to get the DPI. My question is will it be possible to convert the unit of the image, to inches, without knowing the DPI?? I tried using .getheight() and .getwidth() and it does give me the resolution, my problem is I need to convert this to inches. Also, I saw this “dp” in imageview… I’m wondering wheter this has an equivalent value in inches that I can use to convert my image using ratio and proportion. Also found out bitmap.getdensity(). Does that get the actual dpi of the image??