【发布时间】:2017-03-03 00:30:32
【问题描述】:
Camera.Parameters 中的setRotation method 不适用于所有设备。有人建议手动更改EXIF信息来解决问题。您能否给我一个简短的示例,说明如何使用ExifInterface 设置exif 信息,从而将图像方向设置为纵向?
private int savePicture(byte[] data)
{
File pictureFile = getOutputMediaFile();
if (pictureFile == null)
return FILE_CREATION_ERROR;
try {
FileOutputStream fos = new FileOutputStream(pictureFile);
fos.write(data);
fos.close();
} catch (FileNotFoundException e) {
return FILE_NOT_FOUND;
} catch (IOException e) {
return ACCESSING_FILE_ERROR;
}
return OKAY;
}
我试过这个:
try {
ExifInterface exifi = new ExifInterface(pictureFile.getAbsolutePath());
exifi.setAttribute(ExifInterface.TAG_ORIENTATION, String.valueOf(ExifInterface.ORIENTATION_ROTATE_90));
exifi.saveAttributes();
} catch (IOException e) {
Log.e(TAG, "Exif error");
}
但当我从 android 图库中可视化图片时,没有任何变化。
【问题讨论】:
标签: android orientation exif