Config: Add thumb-color option to set a standard color profile #1474

You can leave this blank to disable the conversion from Display P3
to sRGB. We will add more options at a later time.
This commit is contained in:
Michael Mayer 2022-04-06 18:41:15 +02:00
parent 9134c79f4c
commit 4ec7dbc90f
5 changed files with 12 additions and 12 deletions

View file

@ -152,7 +152,7 @@ func configAction(ctx *cli.Context) error {
fmt.Printf("%-25s %s\n", "download-token", conf.DownloadToken())
fmt.Printf("%-25s %s\n", "preview-token", conf.PreviewToken())
fmt.Printf("%-25s %s\n", "thumb-filter", conf.ThumbFilter())
fmt.Printf("%-25s %s\n", "thumb-colorspace", conf.ThumbColorspace())
fmt.Printf("%-25s %s\n", "thumb-color", conf.ThumbColor())
fmt.Printf("%-25s %t\n", "thumb-uncached", conf.ThumbUncached())
fmt.Printf("%-25s %d\n", "thumb-size", conf.ThumbSizePrecached())
fmt.Printf("%-25s %d\n", "thumb-size-uncached", conf.ThumbSizeUncached())

View file

@ -158,7 +158,7 @@ func (c *Config) Propagate() {
log.SetLevel(c.LogLevel())
// Set thumbnail generation parameters.
thumb.StandardRGB = c.ThumbStandardRGB()
thumb.StandardRGB = c.ThumbSRGB()
thumb.SizePrecached = c.ThumbSizePrecached()
thumb.SizeUncached = c.ThumbSizeUncached()
thumb.Filter = c.ThumbFilter()

View file

@ -479,10 +479,10 @@ var GlobalFlags = []cli.Flag{
EnvVar: "PHOTOPRISM_THUMB_FILTER",
},
cli.StringFlag{
Name: "thumb-colorspace",
Usage: "standard colorspace for thumbnails (\"\" to disable)",
Name: "thumb-color",
Usage: "standard color `PROFILE` for thumbnails (leave blank to disable)",
Value: "sRGB",
EnvVar: "PHOTOPRISM_THUMB_COLORSPACE",
EnvVar: "PHOTOPRISM_THUMB_COLOR",
},
cli.BoolFlag{
Name: "thumb-uncached, u",

View file

@ -127,7 +127,7 @@ type Options struct {
DownloadToken string `yaml:"DownloadToken" json:"-" flag:"download-token"`
PreviewToken string `yaml:"PreviewToken" json:"-" flag:"preview-token"`
ThumbFilter string `yaml:"ThumbFilter" json:"ThumbFilter" flag:"thumb-filter"`
ThumbColorspace string `yaml:"ThumbColorspace" json:"ThumbColorspace" flag:"thumb-colorspace"`
ThumbColor string `yaml:"ThumbColor" json:"ThumbColor" flag:"thumb-color"`
ThumbUncached bool `yaml:"ThumbUncached" json:"ThumbUncached" flag:"thumb-uncached"`
ThumbSize int `yaml:"ThumbSize" json:"ThumbSize" flag:"thumb-size"`
ThumbSizeUncached int `yaml:"ThumbSizeUncached" json:"ThumbSizeUncached" flag:"thumb-size-uncached"`

View file

@ -43,14 +43,14 @@ func (c *Config) ThumbPath() string {
return c.CachePath() + "/thumbnails"
}
// ThumbColorspace returns the standard colorspace for thumbnails.
func (c *Config) ThumbColorspace() string {
return c.options.ThumbColorspace
// ThumbColor returns the color profile name for thumbnails.
func (c *Config) ThumbColor() string {
return c.options.ThumbColor
}
// ThumbStandardRGB checks if colors should be normalized to standard RGB in thumbnails.
func (c *Config) ThumbStandardRGB() bool {
return strings.ToLower(c.ThumbColorspace()) == "srgb"
// ThumbSRGB checks if colors should be normalized to standard RGB in thumbnails.
func (c *Config) ThumbSRGB() bool {
return strings.ToLower(c.ThumbColor()) == "srgb"
}
// ThumbUncached checks if on-demand thumbnail rendering is enabled (high memory and cpu usage).