/* EXIF & PANORAMA XMP MetaData Writer */
IImageMetadata metadata = null;
String XmpStringdata = null;
JpegImageMetadata jpegMetadata = null;
TiffImageMetadata exif = null;
TiffOutputSet exifOutputSet = null;
private File CopyImage(String sourcepath, String targetpath) {
File sourceLocation = new File(sourcepath);
File targetLocation = new File(targetpath);
InputStream in = null;
OutputStream out = null;
TiffImageMetadata exif = getExifXmpInfo(sourceLocation);
try {
in = new FileInputStream(sourceLocation);
out = new FileOutputStream(targetLocation);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
// Copy the bits from instream to outstream
byte[] buf = new byte[1024];
int len;
try {
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
} catch (IOException e) {
e.printStackTrace();
}
try {
in.close();
new ExifRewriter().updateExifMetadataLossless(targetLocation, out, exif);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
return targetLocation;
}
public TiffImageMetadata getExifXmpInfo(File sourcepath) {
metadata = null;
XmpStringdata = "";
XmpStringdata = null;
/* Get EXIF & XMP data from Image File */
try {
// EXIF
metadata = Sanselan.getMetadata(sourcepath);
// XMP
XmpStringdata = Sanselan.getXmpXml(sourcepath);
if (metadata == null || !(metadata instanceof JpegImageMetadata))
// comment for no metadata get in 4.3 < device
return null;
jpegMetadata = (JpegImageMetadata) metadata;
exif = jpegMetadata.getExif();
// comment for no metadata get in 4.3 < device
if (exif == null)
return null;
else
return exif;
} catch (ImageReadException | IOException e) {
e.printStackTrace();
return null;
}
}
包括gradle這個罐子庫 https://github.com/fulcrumapp/sanselan-android/releases
添加額外的東西,你需要什麼
https://stackoverflow.com/questions/36593739/i-want-to-read-exif-info-in-image-in-android-i-can-read-exif-from-image-in-gall –
我不想使用exif界面閱讀評論,我想閱讀jpeg文件評論 – Stack
http://help.accusoft.com/ImageGear/v18.2/Windows/ActiveX/IGAX-10-12.html –