Backend: Add blackman resample filter and set default to cubic #157

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-01-13 12:25:16 +01:00
parent c6866bb746
commit ac7382971d
4 changed files with 19 additions and 9 deletions

View file

@ -12,6 +12,11 @@ ENV PHOTOPRISM_PUBLIC true
ENV PHOTOPRISM_EXPERIMENTAL true
ENV PHOTOPRISM_UPLOAD_NSFW false
ENV PHOTOPRISM_HIDE_NSFW false
ENV PHOTOPRISM_THUMB_QUALITY 95
ENV PHOTOPRISM_THUMB_SIZE 3840
ENV PHOTOPRISM_THUMB_LIMIT 3840
ENV PHOTOPRISM_THUMB_ALGORITHM lanczos
ENV PHOTOPRISM_GEOCODING_API places
# Import example photos
RUN photoprism import

View file

@ -239,9 +239,11 @@ func (c *Config) ThumbLimit() int {
return c.config.ThumbLimit
}
// ThumbAlgorithm returns the thumbnail algorithm name (lanczos, cubic or linear).
// ThumbAlgorithm returns the thumbnail resample algorithm (blackman, lanczos, cubic or linear).
func (c *Config) ThumbAlgorithm() thumb.ResampleAlgorithm {
switch strings.ToLower(c.config.ThumbAlgorithm) {
case "blackman":
return thumb.ResampleBlackman
case "lanczos":
return thumb.ResampleLanczos
case "cubic":
@ -249,7 +251,7 @@ func (c *Config) ThumbAlgorithm() thumb.ResampleAlgorithm {
case "linear":
return thumb.ResampleLinear
default:
return thumb.ResampleLanczos
return thumb.ResampleCubic
}
}

View file

@ -238,20 +238,20 @@ var GlobalFlags = []cli.Flag{
},
cli.IntFlag{
Name: "thumb-size, s",
Usage: "pre-rendered thumbnail size limit in pixels (720-3840)",
Usage: "pre-render size limit in pixels (720-3840)",
Value: 2048,
EnvVar: "PHOTOPRISM_THUMB_SIZE",
},
cli.IntFlag{
Name: "thumb-limit, x",
Usage: "on-demand thumbnail size limit in pixels (720-3840)",
Usage: "on-demand size limit in pixels (720-3840)",
Value: 3840,
EnvVar: "PHOTOPRISM_THUMB_LIMIT",
},
cli.StringFlag{
Name: "thumb-algorithm, a",
Usage: "thumbnail algorithm (lanczos, cubic or linear)",
Value: "lanczos",
Usage: "resample algorithm (blackman, lanczos, cubic or linear)",
Value: "cubic",
EnvVar: "PHOTOPRISM_THUMB_ALGORITHM",
},
}

View file

@ -11,15 +11,18 @@ var (
)
const (
ResampleLanczos ResampleAlgorithm = "lanczos"
ResampleCubic = "cubic"
ResampleLinear = "linear"
ResampleBlackman ResampleAlgorithm = "blackman"
ResampleLanczos ResampleAlgorithm = "lanczos"
ResampleCubic ResampleAlgorithm = "cubic"
ResampleLinear ResampleAlgorithm = "linear"
)
type ResampleAlgorithm string
func (a ResampleAlgorithm) Filter() imaging.ResampleFilter {
switch a {
case ResampleBlackman:
return imaging.Blackman
case ResampleLanczos:
return imaging.Lanczos
case ResampleCubic: