8
I have a custom camera application that is used to take pictures and crop them to square, now I want to know how to write Exif data for the final output image (specially the orientation)
Here are the important parts of my code:
captureButton = (Button) findViewById(R.id.button_capture);
captureButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Take a picture
mCamera.takePicture(null, null, mPicture);
}
});
and this is the call back function:
PictureCallback mPicture = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
File pictureFile = getOutputMediaFile();
if (pictureFile == null) {
return;
}
try {
FileOutputStream fos = new FileOutputStream(pictureFile);
fos.write(data);
fos.close();
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
}
};
Update: I Added the following to the onPictureTaken method but nothing changed:
ExifInterface exif;
exif = new ExifInterface(pictureFile.getAbsolutePath());
// Notice getOrientation method gets an Integer with the angle : 0 , 90 , 180 , 270 ..etc
exif.setAttribute(ExifInterface.TAG_ORIENTATION, String.valueOf(getOrientation()) );
exif.saveAttributes();