Record Class ExifInfo
java.lang.Object
java.lang.Record
cloud.opencode.base.image.exif.ExifInfo
- Record Components:
orientation- EXIF orientation value (1-8), 0 if unknown | EXIF 方向值 (1-8),未知为 0cameraMake- camera manufacturer, nullable | 相机制造商,可为 nullcameraModel- camera model, nullable | 相机型号,可为 nulldateTime- date/time the photo was taken, nullable | 拍摄日期时间,可为 nulllatitude- GPS latitude in decimal degrees, nullable | GPS 纬度(十进制度),可为 nulllongitude- GPS longitude in decimal degrees, nullable | GPS 经度(十进制度),可为 nullimageWidth- image width in pixels, nullable | 图片宽度(像素),可为 nullimageHeight- image height in pixels, nullable | 图片高度(像素),可为 nullsoftware- software used to create the image, nullable | 创建图片的软件,可为 null
public record ExifInfo(int orientation, String cameraMake, String cameraModel, Instant dateTime, Double latitude, Double longitude, Integer imageWidth, Integer imageHeight, String software)
extends Record
EXIF Information Record
EXIF 信息记录
Immutable record holding EXIF metadata extracted from a JPEG image. All fields except orientation are nullable, representing absent metadata.
不可变记录,保存从 JPEG 图片中提取的 EXIF 元数据。 除 orientation 外所有字段均可为 null,表示元数据缺失。
Features | 主要功能:
- Hold parsed EXIF metadata - 保存解析后的 EXIF 元数据
- GPS presence check - GPS 存在性检查
- Rotation necessity check - 旋转必要性检查
- Factory method for empty/absent EXIF - 空/缺失 EXIF 的工厂方法
Usage Examples | 使用示例:
ExifInfo info = ExifOp.read(path);
if (info.hasGps()) {
System.out.println("Location: " + info.latitude() + ", " + info.longitude());
}
if (info.needsRotation()) {
BufferedImage corrected = ExifOp.autoOrient(image, info.orientation());
}
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Since:
- JDK 25, opencode-base-image V2.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecameraMakerecord component.Returns the value of thecameraModelrecord component.dateTime()Returns the value of thedateTimerecord component.static ExifInfoempty()Create an empty ExifInfo representing absent or unparseable EXIF data 创建一个空的 ExifInfo,表示缺失或无法解析的 EXIF 数据final booleanIndicates whether some other object is "equal to" this one.booleanhasGps()Check if GPS coordinates are present 检查是否存在 GPS 坐标final inthashCode()Returns a hash code value for this object.Returns the value of theimageHeightrecord component.Returns the value of theimageWidthrecord component.latitude()Returns the value of thelatituderecord component.Returns the value of thelongituderecord component.booleanCheck if the image needs rotation based on EXIF orientation 根据 EXIF 方向检查图片是否需要旋转intReturns the value of theorientationrecord component.software()Returns the value of thesoftwarerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ExifInfo
public ExifInfo(int orientation, String cameraMake, String cameraModel, Instant dateTime, Double latitude, Double longitude, Integer imageWidth, Integer imageHeight, String software) Creates an instance of aExifInforecord class.- Parameters:
orientation- the value for theorientationrecord componentcameraMake- the value for thecameraMakerecord componentcameraModel- the value for thecameraModelrecord componentdateTime- the value for thedateTimerecord componentlatitude- the value for thelatituderecord componentlongitude- the value for thelongituderecord componentimageWidth- the value for theimageWidthrecord componentimageHeight- the value for theimageHeightrecord componentsoftware- the value for thesoftwarerecord component
-
-
Method Details
-
hasGps
public boolean hasGps()Check if GPS coordinates are present 检查是否存在 GPS 坐标- Returns:
- true if both latitude and longitude are present | 当纬度和经度都存在时返回 true
-
needsRotation
public boolean needsRotation()Check if the image needs rotation based on EXIF orientation 根据 EXIF 方向检查图片是否需要旋转- Returns:
- true if orientation is not normal (not 1) | 当方向不正常(非 1)时返回 true
-
empty
Create an empty ExifInfo representing absent or unparseable EXIF data 创建一个空的 ExifInfo,表示缺失或无法解析的 EXIF 数据- Returns:
- an ExifInfo with orientation=0 and all nullable fields null | orientation=0 且所有可空字段为 null 的 ExifInfo
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
orientation
public int orientation()Returns the value of theorientationrecord component.- Returns:
- the value of the
orientationrecord component
-
cameraMake
Returns the value of thecameraMakerecord component.- Returns:
- the value of the
cameraMakerecord component
-
cameraModel
Returns the value of thecameraModelrecord component.- Returns:
- the value of the
cameraModelrecord component
-
dateTime
-
latitude
-
longitude
-
imageWidth
Returns the value of theimageWidthrecord component.- Returns:
- the value of the
imageWidthrecord component
-
imageHeight
Returns the value of theimageHeightrecord component.- Returns:
- the value of the
imageHeightrecord component
-
software
-