Notice
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 폼메일
- 설치
- 자바스크립트
- Android
- WebView
- soundpool
- UML
- FCM
- javascript
- chart.js
- php 취약점
- PHP
- 안드로이드 푸시
- dovecot
- roundcube
- mysql
- 안드로이드 푸쉬
- 우분투
- 자동 생성
- 안드로이드
- xe
- 안드로이드 gcm
- android 효과음
- Mail Server
- curl
- C#
- C# IO
- php 시큐어코딩
- html5
- not working
Archives
- Today
- Total
그러냐
안드로이드(Android) 사진의 EXIF 정보 가져오기 본문
반응형
안드로이드(Android) 사진의 EXIF 정보 가져오기
|
개발환경 : window 7 64bit, Eclipse Mars, Android 4.2.2 |
|
EXIF 란 디지털 사진의 이미지 정보입니다. 아주 다양한 정보가 저장되는데 이미지의 기본값, 크기, 화소등이 있으며 사진을 찍은 카메라 정보, 찍을때 조리개, 노출정도등 이 저장됩니다. 이런 메타 정보들을 활용해서 앱을 만들고자 할 때 사용할수 있는 간단한 샘플입니다. |
먼저 이미지를 읽어오기 위해 에뮬레이터에 하나
추가합니다. 그리고 이미지를 읽어온뒤
ExifInterface 객체를 하나 만들어서 인수로 이미지
주소를 넘깁니다
|
1
2
3
4
5
6
7
8 |
String filename = Environment.getExternalStorageDirectory().getPath() + "/20140705_162816.jpg";try { ExifInterface exif = new ExifInterface(filename); showExif(exif);} catch (IOException e) { e.printStackTrace(); Toast.makeText(this, "Error!", Toast.LENGTH_LONG).show();} |
이렇게 넘어간 ExifInterface 객체를 가지고 구현한
showExif() 함수 입니다. getTagString() 함수를
사용하여 정보를 가져오는데 옵션값과 ExifInterface 객체를
인수값으로 넘깁니다.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 |
private void showExif(ExifInterface exif) { String myAttribute = "[Exif information] \n\n"; myAttribute += getTagString(ExifInterface.TAG_DATETIME, exif); myAttribute += getTagString(ExifInterface.TAG_FLASH, exif); myAttribute += getTagString(ExifInterface.TAG_GPS_LATITUDE, exif); myAttribute += getTagString(ExifInterface.TAG_GPS_LATITUDE_REF, exif); myAttribute += getTagString(ExifInterface.TAG_GPS_LONGITUDE, exif); myAttribute += getTagString(ExifInterface.TAG_GPS_LONGITUDE_REF, exif); myAttribute += getTagString(ExifInterface.TAG_IMAGE_LENGTH, exif); myAttribute += getTagString(ExifInterface.TAG_IMAGE_WIDTH, exif); myAttribute += getTagString(ExifInterface.TAG_MAKE, exif); myAttribute += getTagString(ExifInterface.TAG_MODEL, exif); myAttribute += getTagString(ExifInterface.TAG_ORIENTATION, exif); myAttribute += getTagString(ExifInterface.TAG_WHITE_BALANCE, exif); mView.setText(myAttribute);} |
ExifInterface 의 옵션값은 소스에 있는 것 외에
많이 있으니 다른것들도 추가해서 구현해
보시기 바랍니다.
Exif Information 을 구현한 전체 메인 Activity 의 소스입니다.
메인 레이아웃 xml 은 간단해서 넣지 않았습니다.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 |
import java.io.IOException;import android.app.Activity;import android.media.ExifInterface;import android.os.Bundle;import android.os.Environment;import android.widget.TextView;import android.widget.Toast;public class SampleActivity24 extends Activity { private TextView mView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sample_activity24); mView = (TextView) findViewById(R.id.textview); String filename = Environment.getExternalStorageDirectory() .getPath() + "/20140705_162816.jpg"; try { ExifInterface exif = new ExifInterface(filename); showExif(exif); } catch (IOException e) { e.printStackTrace(); Toast.makeText(this, "Error!", Toast.LENGTH_LONG).show(); } } private void showExif(ExifInterface exif) { String myAttribute = "[Exif information] \n\n"; myAttribute += getTagString(ExifInterface.TAG_DATETIME, exif); myAttribute += getTagString(ExifInterface.TAG_FLASH, exif); myAttribute += getTagString(ExifInterface.TAG_GPS_LATITUDE, exif); myAttribute += getTagString( ExifInterface.TAG_GPS_LATITUDE_REF, exif); myAttribute += getTagString(ExifInterface.TAG_GPS_LONGITUDE, exif); myAttribute += getTagString( ExifInterface.TAG_GPS_LONGITUDE_REF, exif); myAttribute += getTagString(ExifInterface.TAG_IMAGE_LENGTH, exif); myAttribute += getTagString(ExifInterface.TAG_IMAGE_WIDTH, exif); myAttribute += getTagString(ExifInterface.TAG_MAKE, exif); myAttribute += getTagString(ExifInterface.TAG_MODEL, exif); myAttribute += getTagString(ExifInterface.TAG_ORIENTATION, exif); myAttribute += getTagString(ExifInterface.TAG_WHITE_BALANCE, exif); mView.setText(myAttribute); } private String getTagString(String tag, ExifInterface exif) { return (tag + " : " + exif.getAttribute(tag) + "\n"); }} |
반응형
'android' 카테고리의 다른 글
| 안드로이드 Service 에서 Activity 를 실행하는 방법 (0) | 2016.05.26 |
|---|---|
| Android 내장 메모리의 사진 정보 가져오기 (0) | 2016.05.16 |
| 문자 애플리케이션 안드로이드 킷캣(4.4) 대응하기 (0) | 2016.02.01 |
| 안드로이드 웹뷰 만들기> 2. 뒤로 가기, 종료 하기 기능 (0) | 2016.01.28 |
| webview에서 a href=sms: 보내기 (0) | 2016.01.28 |