-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Config: Improve thumbnail generation option parsing and defaults #1474
Signed-off-by: Michael Mayer <michael@photoprism.app>
- Loading branch information
Showing
23 changed files
with
396 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package thumb | ||
|
||
import "github.com/photoprism/photoprism/pkg/clean" | ||
|
||
type ColorSpace = string | ||
|
||
// Supported thumbnail color profiles. | ||
const ( | ||
ColorNone ColorSpace = "none" | ||
ColorAuto ColorSpace = "auto" | ||
ColorSRGB ColorSpace = "srgb" | ||
ColorPreserve ColorSpace = "preserve" | ||
) | ||
|
||
// Color sets the default color profiles for thumbnails. | ||
var Color = ColorAuto | ||
|
||
// ParseColor returns a ColorSpace based on the config value string and image library. | ||
func ParseColor(name string, lib Lib) ColorSpace { | ||
if lib == LibVips { | ||
return ColorPreserve | ||
} | ||
|
||
switch clean.TypeLowerUnderscore(name) { | ||
case ColorNone, "": | ||
return ColorNone | ||
default: | ||
return ColorSRGB | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package thumb | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestParseColor(t *testing.T) { | ||
t.Run("Vips", func(t *testing.T) { | ||
assert.Equal(t, ColorPreserve, ParseColor("", LibVips)) | ||
assert.Equal(t, ColorPreserve, ParseColor(ColorAuto, LibVips)) | ||
assert.Equal(t, ColorPreserve, ParseColor(ColorSRGB, LibVips)) | ||
assert.Equal(t, ColorPreserve, ParseColor(ColorNone, LibVips)) | ||
}) | ||
t.Run("Imaging", func(t *testing.T) { | ||
assert.Equal(t, ColorNone, ParseColor("", LibImaging)) | ||
assert.Equal(t, ColorSRGB, ParseColor(ColorAuto, LibImaging)) | ||
assert.Equal(t, ColorSRGB, ParseColor(ColorSRGB, LibImaging)) | ||
assert.Equal(t, ColorNone, ParseColor(ColorNone, LibImaging)) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.