Documentation
¶
Index ¶
Constants ¶
const ( ExtensionBmp types.FileExtension = ".bmp" // Bitmap Image ExtensionDib types.FileExtension = ".dib" // Device Independent Bitmap ExtensionGif types.FileExtension = ".gif" // Graphics Interchange Format (GIF) ExtensionHeic types.FileExtension = ".heic" // High Efficiency Image Container (HEIC) ExtensionHeif types.FileExtension = ".heif" // High Efficiency Image File Format (HEIF) ExtensionJpg types.FileExtension = ".jpg" // Joint Photographic Experts Group (JPEG) ExtensionJpeg types.FileExtension = ".jpeg" // Joint Photographic Experts Group (JPEG) ExtensionJpe types.FileExtension = ".jpe" // Joint Photographic Experts Group (JPEG) ExtensionJif types.FileExtension = ".jif" // Joint Photographic Experts Group (JPEG) ExtensionJfif types.FileExtension = ".jfif" // Joint Photographic Experts Group (JPEG) ExtensionJfi types.FileExtension = ".jfi" // Joint Photographic Experts Group (JPEG) ExtensionPng types.FileExtension = ".png" // Portable Network Graphics (PNG) ExtensionTiff types.FileExtension = ".tiff" // Tagged Image File Format (TIFF) ExtensionTif types.FileExtension = ".tif" // Tagged Image File Format (TIFF) ExtensionWebp types.FileExtension = ".webp" // Google WebP Image )
List of supported media.Image file extensions.
const ( ImageBmp types.FileType = "bmp" // Bitmap Image ImageGif types.FileType = "gif" // Graphics Interchange Format (GIF) ImageHeic types.FileType = "heic" // High Efficiency Image Container (HEIC) ImageHeif types.FileType = "heif" // High Efficiency Image File Format (HEIF) ImageJpeg types.FileType = "jpg" // Joint Photographic Experts Group (JPEG) ImagePng types.FileType = "png" // Portable Network Graphics (PNG) ImageTiff types.FileType = "tiff" // Tagged Image File Format (TIFF) ImageWebp types.FileType = "webp" // Google WebP Image )
List of supported media.Image file types.
Variables ¶
var ImageFileExtensions = []types.FileExtension{ ExtensionBmp, ExtensionDib, ExtensionGif, ExtensionHeic, ExtensionHeif, ExtensionJpg, ExtensionJpeg, ExtensionJpe, ExtensionJif, ExtensionJfif, ExtensionJfi, ExtensionPng, ExtensionTiff, ExtensionTif, ExtensionWebp, }
ImageFileExtensions is a list of supported media.Image file extensions.
var ImageFileTypes = []types.FileType{ ImageBmp, ImageGif, ImageHeic, ImageHeif, ImageJpeg, ImagePng, ImageTiff, ImageWebp, }
ImageFileTypes is a list of supported media.Image file types.
var ImageFileTypesExtensions = maps.MapFileTypeExtensions{ ImageBmp: {ExtensionBmp, ExtensionDib}, ImageGif: {ExtensionGif}, ImageHeic: {ExtensionHeic}, ImageHeif: {ExtensionHeif}, ImageJpeg: {ExtensionJpg, ExtensionJpeg, ExtensionJpe, ExtensionJif, ExtensionJfif, ExtensionJfi}, ImagePng: {ExtensionPng}, ImageTiff: {ExtensionTiff, ExtensionTif}, ImageWebp: {ExtensionWebp}, }
ImageFileTypesExtensions is a map of media.Image file types to their file extensions.
Functions ¶
Types ¶
type ExifDataParser ¶
type ExifDataParser struct {
// contains filtered or unexported fields
}
ExifDataParser is responsible for extracting and parsing EXIF metadata from images. It maintains a cache of parsed tags to improve performance when processing multiple images.
func NewExifDataParser ¶
func NewExifDataParser() *ExifDataParser
NewExifDataParser creates and initializes a new instance of ExifDataParser. It initializes the tag cache used to store parsed EXIF tags for better performance.
Returns:
- *ExifDataParser: A pointer to the newly created parser instance
func (*ExifDataParser) Parse ¶
func (p *ExifDataParser) Parse(exifData []byte) (ImageData, error)
Parse extracts and processes EXIF metadata from raw image data. It performs a comprehensive extraction of all available EXIF information and organizes it into a structured ImageData object.
Parameters:
- exifData: Raw EXIF data bytes from the image
Returns:
- ImageData: Structured representation of the extracted metadata
- error: Any error encountered during parsing
type ExifParser ¶
type ExifParser struct{}
ExifParser is a struct that contains the EXIF parser.
func NewExifParser ¶
func NewExifParser() *ExifParser
NewExifParser creates a new ExifParser struct.
type ImageData ¶
type ImageData struct {
// GPS information extracted from the EXIF data
GPSLatitude float64 `exif:"GPSLatitude"`
GPSLongitude float64 `exif:"GPSLongitude"`
GPSAltitude float64 `exif:"GPSAltitude"`
GPSTimeZone string // Determined from coordinates
GPSTimestamp time.Time `exif:"GPSDateStamp,GPSTimeStamp"`
GPSTimestampLocal time.Time // Computed from GPSTimestamp and GPSTimeZone
GPSProcessingMethod string `exif:"GPSProcessingMethod"`
GPSStatus string `exif:"GPSStatus"`
GPSSatellites string `exif:"GPSSatellites"`
GPSHPositioningError float64 `exif:"GPSHPositioningError"`
GPSSpeed float64 `exif:"GPSSpeed"`
GPSTrack float64 `exif:"GPSTrack"`
GPSImgDirection float64 `exif:"GPSImgDirection"`
GPSDestLatitude float64 `exif:"GPSDestLatitude"`
GPSDestLongitude float64 `exif:"GPSDestLongitude"`
GPSDestBearing float64 `exif:"GPSDestBearing"`
GPSDestDistance float64 `exif:"GPSDestDistance"`
// Camera information extracted from the EXIF data
CameraMake string `exif:"Make,CameraMake"`
CameraModel string `exif:"Model,CameraModel"`
CameraExposure string `exif:"ExposureTime,Exposure"`
ISOSpeed int `exif:"ISOSpeedRatings,ISO"`
ShutterSpeed string `exif:"ShutterSpeedValue"`
Software string `exif:"Software"`
DateTime time.Time `exif:"DateTime,CreateDate"`
DateTimeOriginal time.Time `exif:"DateTimeOriginal,OriginalDateTime"`
DateTimeDigitized time.Time `exif:"DateTimeDigitized,DigitizedDateTime"`
TimeOffset string `exif:"OffsetTime,OffsetTimeOriginal,OffsetTimeDigitized"` // Format: "+0200" or "-0700"
SubSecOriginal string `exif:"SubSecTimeOriginal,SubSecTime"` // Subsecond precision
HasTimeOffset bool // Indicates if time offset was found
// Lens information extracted from the EXIF data
LensMake string `exif:"LensMake"`
LensModel string `exif:"LensModel,Lens"`
LensFocalLength string `exif:"FocalLength"`
LensAperture string `exif:"FNumber,ApertureValue"`
LensFocalLength35mm string `exif:"FocalLengthIn35mmFilm"`
LensMaxAperture string `exif:"MaxApertureValue"`
LensMinAperture string `exif:"MinApertureValue"`
LensMaxFocalLength string `exif:"MaxFocalLength"`
// Image information
ImageWidth int `exif:"ImageWidth,PixelXDimension,ExifImageWidth,SourceImageWidth"`
ImageHeight int `exif:"ImageHeight,PixelYDimension,ExifImageHeight,SourceImageHeight"`
ImageOrientation int `exif:"Orientation"`
ColorSpace string `exif:"ColorSpace"`
Compression string `exif:"Compression"`
XResolution Rational `exif:"XResolution"`
YResolution Rational `exif:"YResolution"`
ResolutionUnit string `exif:"ResolutionUnit"`
// Additional EXIF information
Artist string `exif:"Artist,Creator"`
Copyright string `exif:"Copyright,CopyrightNotice"`
Description string `exif:"ImageDescription,Description"`
WhiteBalance string `exif:"WhiteBalance"`
Flash string `exif:"Flash,FlashFired"`
MeteringMode string `exif:"MeteringMode"`
ExposureProgram string `exif:"ExposureProgram"`
SceneCaptureType string `exif:"SceneCaptureType"`
SubjectDistance float64 `exif:"SubjectDistance"`
DigitalZoomRatio float64 `exif:"DigitalZoomRatio"`
}
type ImageInfo ¶
type ImageInfo struct {
// File information
FileInfo fs.FileInfo
FileType types.FileType
FileExt types.FileExtension
// Image information
ImageData ImageData
}
ImageInfo is a structure that contains information about an image file. This information are extracted from the image file exif data.
func NewImageInfo ¶
NewImageInfo creates a new ImageInfo struct.
type Rational ¶
Rational represents a rational number with a numerator and a denominator.