diff --git a/internal/photoprism/colors_test.go b/internal/photoprism/colors_test.go index 9406c91b0..eadbedcac 100644 --- a/internal/photoprism/colors_test.go +++ b/internal/photoprism/colors_test.go @@ -23,32 +23,32 @@ func TestMediaFile_Colors_Testdata(t *testing.T) { */ expected := map[string]colors.ColorPerception{ "elephant_mono.jpg": { - Colors: colors.Colors{0x2, 0x2, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0}, + Colors: colors.Colors{0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0}, MainColor: 0, Luminance: colors.LightMap{0xa, 0x9, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0}, Chroma: 0, }, "sharks_blue.jpg": { - Colors: colors.Colors{0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x4, 0x4, 0x6}, + Colors: colors.Colors{0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x5, 0x5, 0x6}, MainColor: 6, Luminance: colors.LightMap{0x9, 0x7, 0x5, 0x4, 0x3, 0x4, 0x3, 0x3, 0x3}, Chroma: 89, }, "cat_black.jpg": { - Colors: colors.Colors{0x2, 0x1, 0x1, 0x1, 0x2, 0x1, 0x2, 0x5, 0x2}, - MainColor: 1, + Colors: colors.Colors{0x1, 0x2, 0x2, 0x2, 0x1, 0x2, 0x1, 0x3, 0x1}, + MainColor: 2, Luminance: colors.LightMap{0x8, 0xc, 0x9, 0x4, 0x2, 0x7, 0xd, 0xd, 0x3}, Chroma: 9, }, "cat_brown.jpg": { - Colors: colors.Colors{0x9, 0x5, 0x1, 0x2, 0x2, 0x1, 0x0, 0x6, 0x2}, - MainColor: 5, + Colors: colors.Colors{0x9, 0x3, 0x2, 0x1, 0x1, 0x2, 0x0, 0x6, 0x1}, + MainColor: 3, Luminance: colors.LightMap{0x4, 0x5, 0xb, 0x4, 0x7, 0x3, 0x2, 0x5, 0x7}, Chroma: 13, }, "cat_yellow_grey.jpg": { - Colors: colors.Colors{0x2, 0x1, 0x1, 0x9, 0x0, 0x5, 0xb, 0x0, 0x5}, - MainColor: 5, + Colors: colors.Colors{0x1, 0x2, 0x2, 0x9, 0x0, 0x3, 0xb, 0x0, 0x3}, + MainColor: 3, Luminance: colors.LightMap{0x9, 0x5, 0xb, 0x6, 0x1, 0x6, 0xa, 0x1, 0x8}, Chroma: 20, }, @@ -113,7 +113,7 @@ func TestMediaFile_Colors(t *testing.T) { assert.Equal(t, "D", p.Chroma.Hex()) assert.IsType(t, colors.Colors{}, p.Colors) assert.Equal(t, "gold", p.MainColor.Name()) - assert.Equal(t, colors.Colors{0x9, 0x5, 0x1, 0x2, 0x2, 0x1, 0x0, 0x6, 0x2}, p.Colors) + assert.Equal(t, colors.Colors{0x9, 0x3, 0x2, 0x1, 0x1, 0x2, 0x0, 0x6, 0x1}, p.Colors) assert.Equal(t, colors.LightMap{0x4, 0x5, 0xb, 0x4, 0x7, 0x3, 0x2, 0x5, 0x7}, p.Luminance) } else { t.Error(err) @@ -149,7 +149,7 @@ func TestMediaFile_Colors(t *testing.T) { assert.Equal(t, "7", p.Chroma.Hex()) assert.IsType(t, colors.Colors{}, p.Colors) assert.Equal(t, "blue", p.MainColor.Name()) - assert.Equal(t, colors.Colors{0x2, 0x6, 0x6, 0x2, 0x2, 0x9, 0x2, 0x0, 0x0}, p.Colors) + assert.Equal(t, colors.Colors{0x1, 0x6, 0x6, 0x1, 0x1, 0x9, 0x1, 0x0, 0x0}, p.Colors) } else { t.Error(err) } @@ -167,7 +167,7 @@ func TestMediaFile_Colors(t *testing.T) { assert.IsType(t, colors.Colors{}, p.Colors) assert.Equal(t, "gold", p.MainColor.Name()) - assert.Equal(t, colors.Colors{0x0, 0x0, 0x1, 0x5, 0x5, 0x0, 0x1, 0x5, 0x0}, p.Colors) + assert.Equal(t, colors.Colors{0x0, 0x0, 0x2, 0x3, 0x3, 0x0, 0x2, 0x3, 0x0}, p.Colors) } else { t.Error(err) } diff --git a/internal/query/photo_search.go b/internal/query/photo_search.go index b07a5f90d..fda3274c1 100644 --- a/internal/query/photo_search.go +++ b/internal/query/photo_search.go @@ -280,7 +280,7 @@ func PhotoSearch(f form.PhotoSearch) (results PhotoResults, count int, err error } if f.Mono { - s = s.Where("files.file_chroma = 0") + s = s.Where("files.file_chroma < 2 OR file_colors = '111111111'") } else if f.Chroma > 9 { s = s.Where("files.file_chroma > ?", f.Chroma) } else if f.Chroma > 0 { diff --git a/pkg/colors/colors.go b/pkg/colors/colors.go index 9c5cf549d..215b31c9d 100644 --- a/pkg/colors/colors.go +++ b/pkg/colors/colors.go @@ -44,11 +44,11 @@ type Chroma uint8 const ( Black Color = iota - Brown Grey + Brown + Gold White Purple - Gold Blue Cyan Teal @@ -82,11 +82,11 @@ var All = Colors{ var Names = map[Color]string{ Black: "black", // 0 - Brown: "brown", // 1 - Grey: "grey", // 2 - White: "white", // 3 - Purple: "purple", // 4 - Gold: "gold", // 5 + Grey: "grey", // 1 + Brown: "brown", // 2 + Gold: "gold", // 3 + White: "white", // 4 + Purple: "purple", // 5 Blue: "blue", // 6 Cyan: "cyan", // 7 Teal: "teal", // 8 @@ -100,22 +100,22 @@ var Names = map[Color]string{ } var Weights = map[Color]uint16{ + Grey: 1, Black: 2, Brown: 2, - Grey: 1, White: 2, + Blue: 3, + Green: 3, Purple: 4, Gold: 4, - Blue: 3, Cyan: 4, Teal: 4, - Green: 3, - Lime: 5, - Yellow: 5, - Magenta: 5, Orange: 4, Red: 4, Pink: 4, + Lime: 5, + Yellow: 5, + Magenta: 5, } func (c Color) Name() string { @@ -181,6 +181,14 @@ var ColorExamples = map[Color]string{ var ColorMap = map[color.RGBA]Color{ {0x00, 0x00, 0x00, 0xff}: Black, + {0xe0, 0xe0, 0xe0, 0xff}: Grey, + {0x9E, 0x9E, 0x9E, 0xff}: Grey, + {0x75, 0x75, 0x75, 0xff}: Grey, + {0x61, 0x61, 0x61, 0xff}: Grey, + {0x42, 0x42, 0x42, 0xff}: Grey, + {0x84, 0x7a, 0x72, 0xff}: Grey, + {0xdf, 0xe0, 0xe1, 0xff}: Grey, + {0xb2, 0xb4, 0x9b, 0xff}: Grey, {0xa1, 0x88, 0x7f, 0xff}: Brown, {0x8d, 0x6e, 0x63, 0xff}: Brown, {0xa0, 0x7f, 0x6c, 0xff}: Brown, @@ -194,14 +202,16 @@ var ColorMap = map[color.RGBA]Color{ {0xaa, 0x80, 0x62, 0xff}: Brown, {0x6b, 0x55, 0x46, 0xff}: Brown, {0xb4, 0xb5, 0x9c, 0xff}: Brown, - {0xb2, 0xb4, 0x9b, 0xff}: Green, - {0xe0, 0xe0, 0xe0, 0xff}: Grey, - {0x9E, 0x9E, 0x9E, 0xff}: Grey, - {0x75, 0x75, 0x75, 0xff}: Grey, - {0x61, 0x61, 0x61, 0xff}: Grey, - {0x42, 0x42, 0x42, 0xff}: Grey, - {0x84, 0x7a, 0x72, 0xff}: Grey, - {0xdf, 0xe0, 0xe1, 0xff}: Grey, + {0xb4, 0x97, 0x6e, 0xff}: Brown, + {0xed, 0xde, 0xac, 0xff}: Gold, + {0xe8, 0xb4, 0x51, 0xff}: Gold, + {0xc0, 0x8a, 0x3e, 0xff}: Gold, + {0xa2, 0x7d, 0x4b, 0xff}: Gold, + {0x75, 0x55, 0x31, 0xff}: Gold, + {0xd1, 0x93, 0x27, 0xff}: Gold, + {0xde, 0xa2, 0x53, 0xff}: Gold, + {0xd5, 0xaa, 0x6f, 0xff}: Gold, + {0xf5, 0xea, 0xd4, 0xff}: Gold, {0xFF, 0xFF, 0xFF, 0xff}: White, {0xe4, 0xe4, 0xe4, 0xff}: White, {0xe7, 0xe7, 0xe7, 0xff}: White, @@ -439,13 +449,4 @@ var ColorMap = map[color.RGBA]Color{ {0x64, 0x07, 0x1a, 0xff}: Magenta, {0x9e, 0x00, 0x47, 0xff}: Magenta, {0xdc, 0x7a, 0xcf, 0xff}: Magenta, - {0xed, 0xde, 0xac, 0xff}: Gold, - {0xe8, 0xb4, 0x51, 0xff}: Gold, - {0xc0, 0x8a, 0x3e, 0xff}: Gold, - {0xa2, 0x7d, 0x4b, 0xff}: Gold, - {0x75, 0x55, 0x31, 0xff}: Gold, - {0xd1, 0x93, 0x27, 0xff}: Gold, - {0xde, 0xa2, 0x53, 0xff}: Gold, - {0xd5, 0xaa, 0x6f, 0xff}: Gold, - {0xf5, 0xea, 0xd4, 0xff}: Gold, }