From 9a9702c9641e1488e69f07e1cb6b1af31410a3dc Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Wed, 10 Aug 2022 15:54:15 +0200 Subject: [PATCH] [bugfix] Check orientation when reading width/height of images (#749) --- internal/media/image.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/media/image.go b/internal/media/image.go index 9dd699dc6..e1fc5c331 100644 --- a/internal/media/image.go +++ b/internal/media/image.go @@ -72,9 +72,12 @@ func decodeImage(r io.Reader, contentType string) (*imageMeta, error) { switch contentType { case mimeImageJpeg: - i, err = jpeg.Decode(r) + i, err = imaging.Decode(r, imaging.AutoOrientation(true)) case mimeImagePng: - i, err = StrippedPngDecode(r) + strippedPngReader := io.Reader(&PNGAncillaryChunkStripper{ + Reader: r, + }) + i, err = imaging.Decode(strippedPngReader, imaging.AutoOrientation(true)) default: err = fmt.Errorf("content type %s not recognised", contentType) }