0

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()?

Community
  • 1
  • 1
lschlessinger
  • 1,934
  • 3
  • 25
  • 47
  • Seems like the title is the other way round? It's saving in landscape, when taken in Portrait -- exactly as in the linked question, isn't it? – Alex Cohn Jun 22 '14 at 19:16
  • Yes, you're absolutely right - silly mistake. – lschlessinger Jun 22 '14 at 19:19
  • It is absolutely legitimate and even preferred to ask such questions in a form of comment to an answer that is incomplete or does not seem clear or does not work for you. – Alex Cohn Jun 22 '14 at 19:33
  • possible duplicate of [Android Camera Intent Saving Image Landscape When Taken Portrait](http://stackoverflow.com/questions/12933085/android-camera-intent-saving-image-landscape-when-taken-portrait) – Alex Cohn Jun 22 '14 at 19:33
  • @AlexCohn ok, even if an answer seems incomplete? I just commented on the post. – lschlessinger Jun 22 '14 at 21:52
  • 1
    @[lschessinger](http://stackoverflow.com/users/2554416/lschessinger): You see it is, both legitimate and efficient! – Alex Cohn Jun 24 '14 at 07:06

1 Answers1

0

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.

Illegal Argument
  • 10,090
  • 2
  • 44
  • 61
  • Thanks for the answer. I meant with respect to that question. How would I define those variables if I had a photo Uri? – lschlessinger Jun 22 '14 at 16:08
  • the answer in the link you gave is not incomplete. You just need to provide appropriate values to the variables he used. I thing changing the file variable to Uri.getPath() would be sufficient – Illegal Argument Jun 22 '14 at 16:15
  • Sorry if I'm missing something, but where is the `resizedBitmap` and `opts` defined? – lschlessinger Jun 22 '14 at 16:20