From bff9c2b3cd0a32a5e67a15125c02e690a425fbce Mon Sep 17 00:00:00 2001 From: David Christofas Date: Mon, 5 Sep 2022 16:33:29 +0200 Subject: [PATCH] auto orientate pictures for thumbnails --- changelog/unreleased/orientate-thumbnails.md | 6 ++++++ services/thumbnails/pkg/preprocessor/preprocessor.go | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/orientate-thumbnails.md diff --git a/changelog/unreleased/orientate-thumbnails.md b/changelog/unreleased/orientate-thumbnails.md new file mode 100644 index 0000000000..96c273c8c0 --- /dev/null +++ b/changelog/unreleased/orientate-thumbnails.md @@ -0,0 +1,6 @@ +Enhancement: Automatically orientate photos when generating thumbnails + +The thumbnailer now makes use of the exif orientation information to automatically orientate pictures before generating thumbnails. + +https://github.com/owncloud/ocis/issues/4477 +https://github.com/owncloud/ocis/pull/4513 diff --git a/services/thumbnails/pkg/preprocessor/preprocessor.go b/services/thumbnails/pkg/preprocessor/preprocessor.go index d0b1acc6f9..89d653cf79 100644 --- a/services/thumbnails/pkg/preprocessor/preprocessor.go +++ b/services/thumbnails/pkg/preprocessor/preprocessor.go @@ -10,6 +10,7 @@ import ( "mime" "strings" + "github.com/disintegration/imaging" "github.com/pkg/errors" "golang.org/x/image/font" "golang.org/x/image/font/opentype" @@ -23,7 +24,7 @@ type FileConverter interface { type ImageDecoder struct{} func (i ImageDecoder) Convert(r io.Reader) (interface{}, error) { - img, _, err := image.Decode(r) + img, err := imaging.Decode(r, imaging.AutoOrientation(true)) if err != nil { return nil, errors.Wrap(err, `could not decode the image`) }