Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Bitmap bitmap = ...
- ByteArrayOutputStream stream = new ByteArrayOutputStream(bitmap);
- bitmap.compress(CompressFormat.JPEG, 70, stream);
- byte[] input = stream.toByteArray();
- String path = ... //bitmap file path
- ExifInterface exif = new ExifInterface(path);
- ... = exif.getAttribute(...)
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- bitmap.compress(CompressFormat.JPEG, 100, bos); //Bitmap object is your image
- byte[] data = bos.toByteArray();
- TiffOutputSet outputSet = null;
- IImageMetadata metadata = Sanselan.getMetadata(new File(filepath)); // filepath is the path to your image file stored in SD card (which contains exif info)
- JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
- if (null != jpegMetadata)
- {
- TiffImageMetadata exif = jpegMetadata.getExif();
- if (null != exif)
- {
- outputSet = exif.getOutputSet();
- }
- }
- if (null != outputSet)
- {
- bos.flush();
- bos.close();
- bos = new ByteArrayOutputStream();
- ExifRewriter ER = new ExifRewriter();
- ER.updateExifMetadataLossless(data, bos, outputSet);
- data = bos.toByteArray(); //Update you Byte array, Now it contains exif information!
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement