3
Apache Commons Imaging을 사용하여 TIFF 이미지에 EXIF 데이터를 쓰려면 어떻게해야합니까?Apache Commons Imaging을 사용하여 TIFF 파일에 EXIF 데이터 쓰기
File img = new File("pic.tif");
File dst = new File("out.tif");
try (FileOutputStream fos = new FileOutputStream(dst);
OutputStream os = new BufferedOutputStream(fos)) {
TiffOutputSet outputSet = null;
final ImageMetadata metadata = Imaging.getMetadata(img);
final TiffImageMetadata tiffMetadata = (TiffImageMetadata) metadata;
outputSet = tiffMetadata.getOutputSet();
if (null == outputSet) {
outputSet = new TiffOutputSet();
}
// New York City
final double longitude = -74.0;
final double latitude = 40 + 43/60.0;
outputSet.setGPSInDegrees(longitude, latitude);
new ExifRewriter().updateExifMetadataLossless(img, os, outputSet);
}
하지만 난이 오류가있어 :
Exception in thread "main" org.apache.commons.imaging.ImageReadException: Not a Valid JPEG File: doesn't begin with 0xffd8
at org.apache.commons.imaging.common.BinaryFunctions.readAndVerifyBytes(BinaryFunctions.java:134)
at org.apache.commons.imaging.formats.jpeg.JpegUtils.traverseJFIF(JpegUtils.java:56)
at org.apache.commons.imaging.formats.jpeg.exif.ExifRewriter.analyzeJFIF(ExifRewriter.java:186)
at org.apache.commons.imaging.formats.jpeg.exif.ExifRewriter.updateExifMetadataLossless(ExifRewriter.java:376)
at org.apache.commons.imaging.formats.jpeg.exif.ExifRewriter.updateExifMetadataLossless(ExifRewriter.java:298)
at Test.main(Test.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
ExifRewriter
클래스는 TIFF를 지원하지 않는 것을 나타냅니다 보인다
이것은 내가 뭘하려? 그렇다면 어떤 수업을 사용해야합니까?
동일한 질문이 있기 때문에 질문을 올리십시오. – Omnipresent