From 37858faacc2d030fb346ee09ee617022e1b08b37 Mon Sep 17 00:00:00 2001 From: drumato Date: Thu, 11 Apr 2024 12:31:10 +0900 Subject: [PATCH] =?UTF-8?q?webp=E4=BB=A5=E5=A4=96=E3=81=AF=E6=98=8E?= =?UTF-8?q?=E7=A4=BA=E7=9A=84=E3=81=AAAutoRotate=E3=81=8C=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E3=81=A0=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: drumato --- convert.go | 9 +++++++-- webp.go | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/convert.go b/convert.go index 5aedec2..3ee14ef 100644 --- a/convert.go +++ b/convert.go @@ -13,12 +13,17 @@ func convert(src io.Reader, q int) (*bytes.Buffer, error) { return nil, err } + // 動作検証の結果こちらは明示的にAutoRotateしないと動かなかった + img, err := bimg.NewImage(out).AutoRotate() + if err != nil { + return nil, err + } + opts := bimg.Options{ Type: bimg.JPEG, Quality: quality, - // NoAutoRotateはデフォルトでfalseで、勝手にrotateしてくれる } - jpegImg, err := bimg.NewImage(out).Process(opts) + jpegImg, err := bimg.NewImage(img).Process(opts) if err != nil { return nil, err } diff --git a/webp.go b/webp.go index 0771f94..9e01eaa 100644 --- a/webp.go +++ b/webp.go @@ -47,8 +47,9 @@ func convWebp(src io.Reader, quality int) (*bytes.Buffer, error) { return nil, err } opts := bimg.Options{ - Type: bimg.WEBP, - Quality: quality, + Type: bimg.WEBP, + Quality: quality, + NoAutoRotate: false, // NoAutoRotateはデフォルトでfalseで、勝手にrotateしてくれる } webpImg, err := bimg.NewImage(out).Process(opts)