0

I am developing a PhotoBook app where I need to notify the user if they add a low-resolution image. I just need to show a "Low-Resolution Image, Printing may be affected" warning as chatbooks app do.

Dr.jacky
  • 3,341
  • 6
  • 53
  • 91
Hitesh Kushwah
  • 1,351
  • 13
  • 23

4 Answers4

1
int file_size = Integer.parseInt(String.valueOf(file.length() / 1024));     
if (file_size < 100){
   Log.v(TAG, "Low resolution image");
 }else{
  Log.v(TAG, "");
 }
Daxesh V
  • 571
  • 6
  • 12
0

you can convert image into bitmap and check its height and width and with this its help you to check the image resolution. if image is from drawable,

 Bitmap bmp = BitmapFactory.decodeResource(res, R.drawable.back);
 bmp.getWidth(), bmp.getHeight();

if image from uri

  Uri imageUri = data.getData();
    Bitmap bitmap = 
  MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri);
  bitmap.getWidth(), bmp.getHeight();

make a validation if image height and width less than your need than show your alert

Amit pandey
  • 1,149
  • 1
  • 4
  • 15
0

If you have a Bitmap object, you can check for bitmap.getWidth() and getHeigth()

770grappenmaker
  • 292
  • 1
  • 7
0

You can check the width and height of the image and thus you can decide which resolution is appropriate to classify it as low quality.

public void checkQuality() {
    String filePathTmp = new File("").getAbsolutePath();//getCanonicalPath();
    //notice you must use you image path
    Path filePath = Paths.get(filePathTmp, "\\YOUR\\PARTH\\IMAGE.png").normalize(); 

    ImageIcon imageIcon = new ImageIcon(filePath.toString());
    int height = imageIcon.getIconHeight();
    int width = imageIcon.getIconWidth();
    System.out.println("HEIGHT: " + height + "--" + "WIDTH" + width);

    //change values, consider your own criteria low quality
    if (height <100 || width <100){
        System.out.println("Low quality");
    }
}
Adonis González
  • 1,978
  • 1
  • 8
  • 14