I'm using the Dropbox Core API to download and display photos. Downloading them and writing to a FileOutputStream is easy enough with:
DropboxAPI.getFile(filePath, null, fos, null);
But the downloaded image is always rotated. If I view the image in my web browser, it displays as upright. But the image written to the FileOutputStream is rotated. Any suggestions as to why this occurs? I can't find anything provided by the metadata that describes how an image should be orientated, but possibly I'm missing something there?
It seems like it would be a mistake to simply check if the image's width is greater than it's height, and to rotate it to portrait orientation based on that?
Related
I've been trying to use the Android ACTION_IMAGE_CAPTURE intent and ACTION_GET_CONTENT intent to either take a photo or pick one. The problem I'm having is that when I when I try to take a photo using the Android photo intent in portrait mode, it saves it in landscape orientation.
I'm trying to save the Bitmap of the correctly orientated photo from a URI string.
I found this question: Android Camera Intent Saving Image Landscape When Taken Portrait, which is the exact same problem I'm having, but the answer is incomplete and didn't work for me. For example, what is the resizedBitmap, opts, and is file Uri.getPath()?
Well some cameras lock the landscape mode as default mode of camera(Samsung note 2) so if you take a picture in potrait mode the image is still saved in landscape mode. Most of the camera will add metadata into the image like the camera vendor, model,etc. Amongst various metadata that can be present the one we are intrested in is the rotation data. It specifies by what degrees the image is to be rotated. For knowing the rotation you can use ExifInterface class.
resizedBitmap Images are stored as bitmap objects in android. As an image can be large loading them whole into memory can lead to outofmemory error's and make your app consume more memory. So a bitmap is first resized to appropriate size and then loaded into memory.
opts By opts you must be referring to BitmapFactory.Options method. It is a class that provides methods to change the behaviour of bitmaps like making it mutable(is set to true you can apply effects like grayscale to this bitmap) , find its height and width in pixels without loading it to RAM,etc.
file Its a class used to perform CRUD operations in any file stored in the system.
Uri.getPath() this method returns the path where your image is stored or null.
I'm currently working of a file explorer for Google Glass and I would like to display a still image for every video I take. They should be bigger than the thumbnails already provided in Android, so I'm guessing I should create them myself from a video.
I'd be grateful if someone could push me into the right diection as to how to find a still image of a video file.
Easy way: Use ThumbnailUtils.createVideoThumbnail(). This will return an image at most 512 * 384 (for MINI_KIND).
You can also do it manually, with MediaMetadataRetriever.getFrameAtTime(). This should return a bitmap with the same dimensions as the video file.
I am writing a Android app which need to display some high quality picture(took from professional DSLR). The problem is it can't be display from gallery.
I choose a photo in Gallery first. The target picture is 2464*1632 JPEG, roughly 4.5M;
Then I just need to compress it to 800*600 and display it in imageview:
image.setImageBitmap(this.bmp);
Thing is that I have tested other image I downloaded form internet(really low quality), and it works without any problem. Can anybody tell me why it can't be displayed? I will be really appericiated
Large images are tricky to handle due to limited memory. You have several choices:
Use a WebView (this allows you to have pinch and zoom functionality to make use of those extra pixels
Decode the image down to the size of the display and then put it in an ImageView using BitmapOpts http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html and changing inSampleSize. It seems you may be having difficulty with that, so consider using createScaledBitmap which just needs the dest width and height.
I do have some images (example) which will be displayed differently depending on the software I am using.
When I open the image in my browser, the picture loads from the right side to the left (in contrast to other images which are loading from top to bottom).
Browser:
When I display the same image in an Android Application (via UrlImageViewHelper) the image will be displayed with an rotation of 90°.
Android:
'Normal' Images (that are loading from the top downwards) are being displayed correctly in my application.
Questions
Where does the browser get the information about the orientation of the image?
How could I implement an Android ImageView that is aware of the original orientation of the image?
Try this:
Put the rotated jpeg in your res/drawable. Set an ImageView to use that. See what happens.
UrlImageViewHelper doesn't actually do special image loading. It just uses the BitmapFactory like it should.
This is very likely to be an Android framework/libjpeg bug where jpeg rotation EXIF tag is not being honored.
I am using the Camera activity to capture the JPEG image. After image is saved and the controll is returned back to my application activity I would like to to determine the captured JPEG image dimensions without loading the whole image into memory via Bitmap object - can it be easily done somehow?
Is there any class, which reads the JPEG header and give me such information? I would like to avoid OOM conditions - but might be it is not a problem to load the whole image into memory - is it?
After knowing the dimensions I would like to use BitmapFactory to scale the image.
Thanks a lot
Kind Regards,
STeN
Perhaps a work-around (see 2nd approach) by setting the quality?
bmp.compress(CompressFormat.JPEG, 75,
pfos);
You would have to do a trial run to see what size the quality gets you though...
*The first approach creates a log file to get the width and height but not sure if you wanted the extra step of looking at a log file.
You can use the ExifInterface class to read the image width and height.