2020-01-07 17:36:49 +01:00
|
|
|
package meta
|
|
|
|
|
|
|
|
import (
|
2020-05-14 11:57:26 +02:00
|
|
|
"math"
|
2020-01-07 17:36:49 +01:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2020-01-07 18:13:53 +01:00
|
|
|
// Data represents image meta data.
|
2020-01-07 17:36:49 +01:00
|
|
|
type Data struct {
|
2020-05-13 21:22:49 +02:00
|
|
|
UniqueID string `meta:"ImageUniqueID"`
|
2020-05-16 09:27:21 +02:00
|
|
|
TakenAt time.Time `meta:"DateTimeOriginal,CreateDate,MediaCreateDate,DateTimeDigitized,DateTime"`
|
|
|
|
TakenAtLocal time.Time `meta:"DateTimeOriginal,CreateDate,MediaCreateDate,DateTimeDigitized,DateTime"`
|
2020-05-13 21:22:49 +02:00
|
|
|
TimeZone string `meta:"-"`
|
2020-05-15 09:39:32 +02:00
|
|
|
Duration time.Duration `meta:"Duration,MediaDuration,TrackDuration"`
|
|
|
|
Codec string `meta:"CompressorID,Compression"`
|
2020-05-13 21:22:49 +02:00
|
|
|
Title string `meta:"Title"`
|
2020-05-14 11:57:26 +02:00
|
|
|
Subject string `meta:"Subject,PersonInImage"`
|
2020-05-13 21:22:49 +02:00
|
|
|
Keywords string `meta:"Keywords"`
|
|
|
|
Comment string `meta:"-"`
|
|
|
|
Artist string `meta:"Artist,Creator"`
|
|
|
|
Description string `meta:"Description"`
|
|
|
|
Copyright string `meta:"Rights,Copyright"`
|
|
|
|
CameraMake string `meta:"CameraMake,Make"`
|
|
|
|
CameraModel string `meta:"CameraModel,Model"`
|
|
|
|
CameraOwner string `meta:"OwnerName"`
|
|
|
|
CameraSerial string `meta:"SerialNumber"`
|
|
|
|
LensMake string `meta:"LensMake"`
|
|
|
|
LensModel string `meta:"Lens,LensModel"`
|
|
|
|
Flash bool `meta:"-"`
|
|
|
|
FocalLength int `meta:"-"`
|
|
|
|
Exposure string `meta:"ExposureTime"`
|
|
|
|
Aperture float32 `meta:"ApertureValue"`
|
|
|
|
FNumber float32 `meta:"FNumber"`
|
|
|
|
Iso int `meta:"ISO"`
|
|
|
|
GPSPosition string `meta:"GPSPosition"`
|
2020-05-14 11:57:26 +02:00
|
|
|
GPSLatitude string `meta:"GPSLatitude"`
|
|
|
|
GPSLongitude string `meta:"GPSLongitude"`
|
|
|
|
Lat float32 `meta:"-"`
|
|
|
|
Lng float32 `meta:"-"`
|
|
|
|
Altitude int `meta:"GlobalAltitude"`
|
2020-05-18 17:38:14 +02:00
|
|
|
Width int `meta:"PixelXDimension,ImageWidth,ExifImageWidth,SourceImageWidth"`
|
|
|
|
Height int `meta:"PixelYDimension,ImageHeight,ImageLength,ExifImageHeight,SourceImageHeight"`
|
2020-05-13 21:22:49 +02:00
|
|
|
Orientation int `meta:"-"`
|
2020-05-14 14:28:23 +02:00
|
|
|
Rotation int `meta:"Rotation"`
|
2020-05-13 21:22:49 +02:00
|
|
|
All map[string]string
|
2020-01-07 17:36:49 +01:00
|
|
|
}
|
2020-05-14 11:57:26 +02:00
|
|
|
|
|
|
|
// AspectRatio returns the aspect ratio based on width and height.
|
|
|
|
func (data Data) AspectRatio() float32 {
|
|
|
|
width := float64(data.Width)
|
|
|
|
height := float64(data.Height)
|
|
|
|
|
|
|
|
if width <= 0 || height <= 0 {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
aspectRatio := float32(width / height)
|
|
|
|
|
|
|
|
return aspectRatio
|
|
|
|
}
|
|
|
|
|
|
|
|
// Portrait returns true if it's a portrait picture or video based on width and height.
|
|
|
|
func (data Data) Portrait() bool {
|
|
|
|
return data.Width < data.Height
|
|
|
|
}
|
|
|
|
|
|
|
|
// Megapixels returns the resolution in megapixels.
|
|
|
|
func (data Data) Megapixels() int {
|
|
|
|
return int(math.Round(float64(data.Width*data.Height) / 1000000))
|
|
|
|
}
|