0

I experience some problems with files, created from android Bitmap.

On my Samsung device, photos from camera are rotated, and they have orientation info in EXIF data, that saying to programs, how to display them properly. If i'm opening info from Preview program (Mac) on that files, i see 3 tabs there: General, EXIF and TIFF:

But if i'm copying that file (i need to resize it for smaller dimensions) over reading, resizing and writing Bitmap, resulting file is effectively rotated. Info for this file has 2 tabs: General and JFIF.

So i tried to rotate Bitmap after resizing over Matrix.postRotate() , depending on EXIF of original file. Matrix is rotating successfully, but after saving that file it's info has 2 tabs: General and TIFF

There's no JFIF or EXIF data, so it has no density in description, and some programs are not able to read it, although in Android it been read successfully.

How can i add correct info for that new file after rotation? I really need help with this, because google search gave no information...

formatBCE
  • 159
  • 1
  • 12
  • you probably created a new image at some point, which means only the information you explicitly copy over will be preserved. e.g. if you don't copy the exif info to the new image object, it'll be "lost"... – Marc B Jan 14 '16 at 15:18
  • @MarcB thank you for answer. Yes, new file is created, but as you can see, there is some EXIF data in rotated file - i'm copying them explicitly. Case is, that EXIF header is written to file by cameras, and all copied files have JFIF data instead - it is correct header for JPEG file. – formatBCE Jan 14 '16 at 15:42
  • Have a look at [`ExifInterface`](http://developer.android.com/reference/android/media/ExifInterface.html). – Mike M. Jan 14 '16 at 16:18
  • @MikeM. thanks. That's exactly what i did with newly created image - get EXIF data from original image, and wrote it to new. You can see manufacturer, model, orientation and so on for my rotated copy (last two screenshots). But it isn't help. – formatBCE Jan 14 '16 at 16:32
  • Oh, yeah, my bad. I guess I didn't read your question closely enough. You might have to either use a third-party library for that, or just do it yourself. The [JFIF file format](https://en.wikipedia.org/wiki/JPEG_File_Interchange_Format) isn't too terribly difficult to deal with. I also found [this post](http://stackoverflow.com/questions/21879142/android-how-to-get-or-set-print-dpi-dots-per-inch-of-jpeg-file-while-loa) that demonstrates how to set the units and X/Y density, that might be of some help. – Mike M. Jan 14 '16 at 17:03
  • 1
    @MikeM. Thank you very much! Link you provided was actually that i needed! – formatBCE Jan 19 '16 at 12:00
  • @MikeM. By the way, could you transfer your answer to actual answer - then i'll be able to mark it as accepted. :) – formatBCE Jan 20 '16 at 11:23
  • Actually, if that post is what you're looking for, I'll just vote this as a duplicate, and you can mark it as helpful to close out your question. I don't wanna take any credit for somebody else's answer. Thanks, though. Cheers! – Mike M. Jan 20 '16 at 11:27

0 Answers0