|
|
|
@ -4,6 +4,9 @@ import com.drew.metadata.Directory;
|
|
|
|
|
import com.drew.metadata.Metadata;
|
|
|
|
|
import com.drew.metadata.Tag;
|
|
|
|
|
import com.drew.metadata.exif.ExifSubIFDDirectory;
|
|
|
|
|
import org.apache.commons.imaging.ImageInfo;
|
|
|
|
|
import org.apache.commons.imaging.ImageReadException;
|
|
|
|
|
import org.apache.commons.imaging.Imaging;
|
|
|
|
|
|
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
|
import java.io.File;
|
|
|
|
@ -31,31 +34,34 @@ public class JpmTest {
|
|
|
|
|
// 查询特定Tag:拍摄日期(OS X上叫内容创建时间)
|
|
|
|
|
Date date = directory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL);
|
|
|
|
|
}
|
|
|
|
|
public static void main(String[] args) throws ImageProcessingException, IOException {
|
|
|
|
|
// File file = new File("C:\\Users\\zhanghai\\Documents\\WeChat Files\\wxid_wexo4ubjorso22\\FileStorage\\File\\2023-11\\JP2/16-35数转模 - 0001.jp2");
|
|
|
|
|
// ImageInfo imageInfo = Imaging.getImageInfo(file);
|
|
|
|
|
// int height = imageInfo.getHeight();
|
|
|
|
|
// int width = imageInfo.getWidth();
|
|
|
|
|
// int physicalHeightDpi = imageInfo.getPhysicalHeightDpi();
|
|
|
|
|
public static void main(String[] args) throws ImageProcessingException, IOException, ImageReadException {
|
|
|
|
|
File file = new File("C:\\Users\\zhanghai\\Documents\\WeChat Files\\wxid_wexo4ubjorso22\\FileStorage\\File\\2023-11\\GIF\\新建文件夹 - 副本 - 副本/0000007.gif");
|
|
|
|
|
ImageInfo imageInfo = Imaging.getImageInfo(file);
|
|
|
|
|
int height = imageInfo.getHeight();
|
|
|
|
|
int width = imageInfo.getWidth();
|
|
|
|
|
System.out.println(height);
|
|
|
|
|
System.out.println(width);
|
|
|
|
|
int physicalHeightDpi = imageInfo.getPhysicalHeightDpi();
|
|
|
|
|
System.out.println(physicalHeightDpi);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String filePath = "C:\\Users\\zhanghai\\Documents\\WeChat Files\\wxid_wexo4ubjorso22\\FileStorage\\File\\2023-11\\1.jpm"; // 替换成你的 JP2 图像文件路径
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 读取 JPEG 2000 图像文件
|
|
|
|
|
File inputFile = new File(filePath);
|
|
|
|
|
BufferedImage image = ImageIO.read(inputFile);
|
|
|
|
|
// ImageInfo imageInfo = Imaging.getImageInfo(inputFile);
|
|
|
|
|
int height = image.getHeight();
|
|
|
|
|
int width = image.getWidth();
|
|
|
|
|
// int physicalHeightDpi = image.getPhysicalHeightDpi();
|
|
|
|
|
System.out.println(height);
|
|
|
|
|
System.out.println(width);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
// String filePath = "C:\\Users\\zhanghai\\Documents\\WeChat Files\\wxid_wexo4ubjorso22\\FileStorage\\File\\2023-11\\1.jpm"; // 替换成你的 JP2 图像文件路径
|
|
|
|
|
//
|
|
|
|
|
// try {
|
|
|
|
|
// // 读取 JPEG 2000 图像文件
|
|
|
|
|
// File inputFile = new File(filePath);
|
|
|
|
|
// BufferedImage image = ImageIO.read(inputFile);
|
|
|
|
|
//// ImageInfo imageInfo = Imaging.getImageInfo(inputFile);
|
|
|
|
|
// int height = image.getHeight();
|
|
|
|
|
// int width = image.getWidth();
|
|
|
|
|
//// int physicalHeightDpi = image.getPhysicalHeightDpi();
|
|
|
|
|
// System.out.println(height);
|
|
|
|
|
// System.out.println(width);
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// new JpmTest().viewExif(filePath);
|
|
|
|
|
}
|
|
|
|
|