Indexer: Set a default color for photos with multiple files #715
This commit is contained in:
parent
3d7c9323d8
commit
859e4f7d8c
|
@ -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: "",
|
||||
|
|
|
@ -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:"-"`
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue