diff --git a/frontend/src/model/photo.js b/frontend/src/model/photo.js index 06ddcebd0..75cee0d81 100644 --- a/frontend/src/model/photo.js +++ b/frontend/src/model/photo.js @@ -43,7 +43,7 @@ export const FormatMp4 = "mp4"; export const FormatAvc = "avc"; export const FormatJpeg = "jpg"; export const TypeImage = "image"; -export const TypeVideo= "video"; +export const TypeVideo = "video"; export const TypeLive = "live"; export const TypeRaw = "raw"; export const YearUnknown = -1; @@ -67,7 +67,7 @@ export class Photo extends RestModel { TakenSrc: "", TimeZone: "", Path: "", - Color: "", + Color: 0, Name: "", OriginalName: "", Title: "", diff --git a/internal/entity/photo.go b/internal/entity/photo.go index 7257204c6..ca936d255 100644 --- a/internal/entity/photo.go +++ b/internal/entity/photo.go @@ -80,6 +80,7 @@ type Photo struct { PhotoFocalLength int `json:"FocalLength" yaml:"FocalLength,omitempty"` PhotoQuality int `gorm:"type:SMALLINT" json:"Quality" yaml:"-"` PhotoResolution int `gorm:"type:SMALLINT" json:"Resolution" yaml:"-"` + PhotoColor uint8 `json:"Color" yaml:"-"` CameraID uint `gorm:"index:idx_photos_camera_lens;default:1" json:"CameraID" yaml:"-"` CameraSerial string `gorm:"type:VARBINARY(255);" json:"CameraSerial" yaml:"CameraSerial,omitempty"` CameraSrc string `gorm:"type:VARBINARY(8);" json:"CameraSrc" yaml:"-"` diff --git a/internal/photoprism/index_mediafile.go b/internal/photoprism/index_mediafile.go index 72b472ce8..218edae3f 100644 --- a/internal/photoprism/index_mediafile.go +++ b/internal/photoprism/index_mediafile.go @@ -305,6 +305,10 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) ( file.FileLuminance = p.Luminance.Hex() file.FileDiff = p.Luminance.Diff() file.FileChroma = p.Chroma.Value() + + if file.FilePrimary { + photo.PhotoColor = p.MainColor.Uint8() + } } if m.Width() > 0 && m.Height() > 0 { diff --git a/internal/query/photo_results.go b/internal/query/photo_results.go index 06cc2f47c..e98bbaed2 100644 --- a/internal/query/photo_results.go +++ b/internal/query/photo_results.go @@ -40,6 +40,7 @@ type PhotoResult struct { PhotoExposure string `json:"Exposure"` PhotoQuality int `json:"Quality"` PhotoResolution int `json:"Resolution"` + PhotoColor uint8 `json:"Color"` PhotoScan bool `json:"Scan"` PhotoPanorama bool `json:"Panorama"` CameraID uint `json:"CameraID"` // Camera diff --git a/internal/query/photo_search.go b/internal/query/photo_search.go index fda3274c1..b655940d8 100644 --- a/internal/query/photo_search.go +++ b/internal/query/photo_search.go @@ -358,7 +358,7 @@ func PhotoSearch(f form.PhotoSearch) (results PhotoResults, count int, err error s = s.Order("photos.id DESC, files.file_primary DESC") case entity.SortOrderSimilar: s = s.Where("files.file_diff > 0") - s = s.Order("files.file_main_color, photos.cell_id, files.file_diff, taken_at DESC, files.file_primary DESC") + s = s.Order("photos.photo_color, photos.cell_id, files.file_diff, taken_at DESC, files.file_primary DESC") case entity.SortOrderName: s = s.Order("photos.photo_path, photos.photo_name, files.file_primary DESC") default: diff --git a/pkg/colors/colors.go b/pkg/colors/colors.go index 215b31c9d..0b90f7adc 100644 --- a/pkg/colors/colors.go +++ b/pkg/colors/colors.go @@ -37,7 +37,7 @@ import ( "strings" ) -type Color uint16 +type Color uint8 type Colors []Color type Chroma uint8 @@ -122,6 +122,10 @@ func (c Color) Name() string { return Names[c] } +func (c Color) Uint8() uint8 { + return uint8(c) +} + func (c Color) Hex() string { return fmt.Sprintf("%X", c) }