Detecting jpeg rotation


I have a photo that is displayed as portrait on my phone, but processing interprets it as landscape. It seems processing (at least processing for android) does not read the “rotation” flag from the jpeg file.

I can manage to rotate an image, but what I can’t manage is to discover which jpg images have this “rotation” flag.

Is there a way to read this info from an image?