Indexer: Set a default color for photos with multiple files #715

This commit is contained in:
Michael Mayer 2020-12-17 12:32:53 +01:00
parent 3d7c9323d8
commit 859e4f7d8c
6 changed files with 14 additions and 4 deletions

View file

@ -43,7 +43,7 @@ export const FormatMp4 = "mp4";
export const FormatAvc = "avc"; export const FormatAvc = "avc";
export const FormatJpeg = "jpg"; export const FormatJpeg = "jpg";
export const TypeImage = "image"; export const TypeImage = "image";
export const TypeVideo= "video"; export const TypeVideo = "video";
export const TypeLive = "live"; export const TypeLive = "live";
export const TypeRaw = "raw"; export const TypeRaw = "raw";
export const YearUnknown = -1; export const YearUnknown = -1;
@ -67,7 +67,7 @@ export class Photo extends RestModel {
TakenSrc: "", TakenSrc: "",
TimeZone: "", TimeZone: "",
Path: "", Path: "",
Color: "", Color: 0,
Name: "", Name: "",
OriginalName: "", OriginalName: "",
Title: "", Title: "",

View file

@ -80,6 +80,7 @@ type Photo struct {
PhotoFocalLength int `json:"FocalLength" yaml:"FocalLength,omitempty"` PhotoFocalLength int `json:"FocalLength" yaml:"FocalLength,omitempty"`
PhotoQuality int `gorm:"type:SMALLINT" json:"Quality" yaml:"-"` PhotoQuality int `gorm:"type:SMALLINT" json:"Quality" yaml:"-"`
PhotoResolution int `gorm:"type:SMALLINT" json:"Resolution" 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:"-"` CameraID uint `gorm:"index:idx_photos_camera_lens;default:1" json:"CameraID" yaml:"-"`
CameraSerial string `gorm:"type:VARBINARY(255);" json:"CameraSerial" yaml:"CameraSerial,omitempty"` CameraSerial string `gorm:"type:VARBINARY(255);" json:"CameraSerial" yaml:"CameraSerial,omitempty"`
CameraSrc string `gorm:"type:VARBINARY(8);" json:"CameraSrc" yaml:"-"` CameraSrc string `gorm:"type:VARBINARY(8);" json:"CameraSrc" yaml:"-"`

View file

@ -305,6 +305,10 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) (
file.FileLuminance = p.Luminance.Hex() file.FileLuminance = p.Luminance.Hex()
file.FileDiff = p.Luminance.Diff() file.FileDiff = p.Luminance.Diff()
file.FileChroma = p.Chroma.Value() file.FileChroma = p.Chroma.Value()
if file.FilePrimary {
photo.PhotoColor = p.MainColor.Uint8()
}
} }
if m.Width() > 0 && m.Height() > 0 { if m.Width() > 0 && m.Height() > 0 {

View file

@ -40,6 +40,7 @@ type PhotoResult struct {
PhotoExposure string `json:"Exposure"` PhotoExposure string `json:"Exposure"`
PhotoQuality int `json:"Quality"` PhotoQuality int `json:"Quality"`
PhotoResolution int `json:"Resolution"` PhotoResolution int `json:"Resolution"`
PhotoColor uint8 `json:"Color"`
PhotoScan bool `json:"Scan"` PhotoScan bool `json:"Scan"`
PhotoPanorama bool `json:"Panorama"` PhotoPanorama bool `json:"Panorama"`
CameraID uint `json:"CameraID"` // Camera CameraID uint `json:"CameraID"` // Camera

View file

@ -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") s = s.Order("photos.id DESC, files.file_primary DESC")
case entity.SortOrderSimilar: case entity.SortOrderSimilar:
s = s.Where("files.file_diff > 0") 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: case entity.SortOrderName:
s = s.Order("photos.photo_path, photos.photo_name, files.file_primary DESC") s = s.Order("photos.photo_path, photos.photo_name, files.file_primary DESC")
default: default:

View file

@ -37,7 +37,7 @@ import (
"strings" "strings"
) )
type Color uint16 type Color uint8
type Colors []Color type Colors []Color
type Chroma uint8 type Chroma uint8
@ -122,6 +122,10 @@ func (c Color) Name() string {
return Names[c] return Names[c]
} }
func (c Color) Uint8() uint8 {
return uint8(c)
}
func (c Color) Hex() string { func (c Color) Hex() string {
return fmt.Sprintf("%X", c) return fmt.Sprintf("%X", c)
} }