grantespo
grantespo

Reputation: 2269

How to check if image in gallery was taken from camera or screenshot?

I am uploading an image from my gallery and setting it as a bitmap. In my scenario, whenever I upload a screenshot from gallery,

The bitmap looks clean and fit

But, when I upload a picture which was taken from back/front camera, the bitmap is rotated 90 degrees.

How do I detect if an gallery image was taken by camera or screenshot?

Upvotes: 2

Views: 2200

Answers (2)

Sámal Rasmussen
Sámal Rasmussen

Reputation: 3495

This isn't a great solution, but it's something ¯\_(ツ)_/¯

filename.contains("screenshot", ignoreCase = true)

Upvotes: 0

Damia Fuentes
Damia Fuentes

Reputation: 5493

Check if the dimensions of the image fits with the dimensions of the screen. Considering bitmap is the image you want to check:

Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
if(bitmap.getWidth() == size.x && bitmap.getHeight() == size.y){
    // Then is a screenshot
}else{
    // Then is not a screenshot
}

Upvotes: 2

Related Questions