글
그래서 이것을 유지시켜주는 유틸을 만들었다.
먼저 크기는 변경되기 때문에 크기의 exif 정보만 빼고 나머지를 그대로 복사하는 copyExifWithoutLengthWitdth 함수를 정의한다.
private static void copyExifWithoutLengthWidth(ExifInterface src,ExifInterface dest) {
for (Field f:ExifInterface.class.getFields()) {
String name = f.getName();
if (!name.startsWith("TAG_")) {
continue;
}
String key = null;
try {
key = (String)f.get(null);
} catch (Exception e) {
continue;
}
if (key == null) {
continue;
}
if (key.equals(ExifInterface.TAG_IMAGE_LENGTH) || key.equals(ExifInterface.TAG_IMAGE_WIDTH)) {
continue;
}
String value = src.getAttribute(key);
if (value == null) {
continue;
}
dest.setAttribute(key, value);
}
}
다음으로 위 함수를 이용해서 아래와같이 작성하면 간단하게 복사된다.
ExifInterface originalExif = new ExifInterface(originalFile.getAbsolutePath());
ExifInterface finalExif = new ExifInterface(finalFile.getAbsolutePath());
copyExifWithoutLengthWidth(originalExif,finalExif);
finalExif.saveAttributes();
'알짜정보 > Android' 카테고리의 다른 글
android 에서 헤더섹션이 떠있는 리스트뷰 (PinnedHeaderListView) 구현. (31) | 2012.03.26 |
---|---|
android ADT r17 x86 에뮬레이터 (20) | 2012.03.23 |
android webview 에서 파일 업로드 하기 (32) | 2012.02.29 |
ant 를 이용해서 android 에뮬레이터 컨트롤하기 (91) | 2012.02.24 |
ant 를 이용한 android 자동 빌드환경 구성 (41) | 2012.01.30 |
RECENT COMMENT