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.
Asked
Active
Viewed 2,070 times
0
-
You can check through image size. like long length = file.length() / 1024; – Daxesh V Mar 17 '20 at 07:57
-
how can you explain – Hitesh Kushwah Mar 17 '20 at 07:58
-
you can set a condition like if image size is < 100 kb then shows an alert message. – Daxesh V Mar 17 '20 at 08:02
-
Check https://mathematica.stackexchange.com/questions/71726/how-can-i-detect-if-an-image-is-of-poor-quality – Gad D Lord Mar 26 '22 at 22:51
4 Answers
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