How to get the dpi of an image(Java)

后端 未结 7 1934
无人及你
无人及你 2021-01-06 01:51

In c#, we can use Image.HorizontalResolution and Image.VerticalResolution.

But in java, how to get it?

I found ImageInfo.java, but it only supp

7条回答
  •  旧时难觅i
    2021-01-06 02:03

    Find dpi of .bmp image use :

    import com.lowagie.text.Image.
    
        public class BitmapResolution {
            public static void main(String args[]) {
                try {
                    Image img = Image.getInstance("C:/Users/AngryMan/Desktop/img003.bmp");
                    System.out.println(img.getDpiX());
                    System.out.println(img.getDpiY());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    

    Maven Dependency :

            
            
                com.lowagie
                itext
                2.1.7
                 
    

提交回复
热议问题