aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-06-25 20:45:43 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-06-25 20:45:43 +0200
commite1c8bb1bd5381d8ade3c699a2d6b4fb373112880 (patch)
tree924317fecd5f55c29c287d89dc5627bbbd73327c /pkg
parent249ee195ce52ee4a4defeb67a33ef353919d3a11 (diff)
downloadlens-e1c8bb1bd5381d8ade3c699a2d6b4fb373112880.tar.gz
lens-e1c8bb1bd5381d8ade3c699a2d6b4fb373112880.tar.bz2
lens-e1c8bb1bd5381d8ade3c699a2d6b4fb373112880.zip
feat: Store image size
Add image dimensions to exif fetch.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/components/media/model.go2
-rw-r--r--pkg/database/sql/media.go6
-rw-r--r--pkg/fileop/exif.go11
3 files changed, 19 insertions, 0 deletions
diff --git a/pkg/components/media/model.go b/pkg/components/media/model.go
index f5c9ff6..0e17e92 100644
--- a/pkg/components/media/model.go
+++ b/pkg/components/media/model.go
@@ -15,6 +15,8 @@ type (
}
MediaEXIF struct {
+ Width *float64
+ Height *float64
Description *string
Camera *string
Maker *string
diff --git a/pkg/database/sql/media.go b/pkg/database/sql/media.go
index 59a4b83..3446f79 100644
--- a/pkg/database/sql/media.go
+++ b/pkg/database/sql/media.go
@@ -21,6 +21,8 @@ type (
MediaEXIF struct {
gorm.Model
+ Width *float64
+ Height *float64
MediaID uint
Media Media
Description *string
@@ -58,6 +60,8 @@ func (self *Media) ToModel() *media.Media {
func (m *MediaEXIF) ToModel() *media.MediaEXIF {
return &media.MediaEXIF{
+ Height: m.Height,
+ Width: m.Width,
Description: m.Description,
Camera: m.Camera,
Maker: m.Maker,
@@ -188,6 +192,8 @@ func (m *MediaRepository) GetEXIF(ctx context.Context, mediaID uint) (*media.Med
func (s *MediaRepository) CreateEXIF(ctx context.Context, id uint, info *media.MediaEXIF) error {
media := &MediaEXIF{
MediaID: id,
+ Width: info.Width,
+ Height: info.Height,
Description: info.Description,
Camera: info.Camera,
Maker: info.Maker,
diff --git a/pkg/fileop/exif.go b/pkg/fileop/exif.go
index c2449ad..79716eb 100644
--- a/pkg/fileop/exif.go
+++ b/pkg/fileop/exif.go
@@ -37,6 +37,17 @@ func ReadExif(path string) (*media.MediaEXIF, error) {
newExif.Maker = &make
}
+ // Get Image Size
+ width, err := fileInfo.GetFloat("ImageWidth")
+ if err == nil {
+ newExif.Width = &width
+ }
+
+ height, err := fileInfo.GetFloat("ImageHeight")
+ if err == nil {
+ newExif.Height = &height
+ }
+
// Get lens
lens, err := fileInfo.GetString("LensModel")
if err == nil {