I am setting an image to ImageView, however the image is not picked from the device storage, the image is sent by the server, I want to know about the orientation of the image before setting it to the imageview. So, is it possible to check the orientation the jpg image coming from the server using its url and ExifInterface and then change its orientation as per required to set to the imageview?
Asked
Active
Viewed 1,890 times
1
-
1No you can't. What you can however, is when you have the image, to determine if the width is larger than the heigh, then you know that the image is in landscape etc. – g00dy Aug 05 '13 at 07:40
-
yes, i'm talking about the image orientation. isn't it possible to change that.. @Mocialov Boris – user2416657 Aug 05 '13 at 07:47
3 Answers
0
No determining orientation is not possible. You will have to check the width and height and align the images accordingly to your ImageView.

Girish K Gupta
- 190
- 1
- 7
0
Maybe this could help you
void readAndDisplayMetadata( String fileName ) {
try {
File file = new File( fileName );
ImageInputStream iis = ImageIO.createImageInputStream(file);
Iterator<ImageReader> readers = ImageIO.getImageReaders(iis);
if (readers.hasNext()) {
// pick the first available ImageReader
ImageReader reader = readers.next();
// attach source to the reader
reader.setInput(iis, true);
// read metadata of first image
IIOMetadata metadata = reader.getImageMetadata(0);
String[] names = metadata.getMetadataFormatNames();
int length = names.length;
for (int i = 0; i < length; i++) {
System.out.println( "Format name: " + names[ i ] );
displayMetadata(metadata.getAsTree(names[i]));
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}
http://johnbokma.com/java/obtaining-image-metadata.html
Note: If you are sure that image is portrait if and only if your images height is higher than its width, you could measure them to find its orientation.

Orhun Mert Simsek
- 437
- 5
- 25
0
You can check like this : Android : How to detect the image orientation (portrait or landscape) picked from gallery while setting on an imageview?

Community
- 1
- 1

Harish Godara
- 2,388
- 1
- 14
- 28
-
i don't want to set the image picked from image gallery or from the local storage... – user2416657 Aug 05 '13 at 07:50