Skip to content

Commit

Permalink
webp以外は明示的なAutoRotateが必要だった
Browse files Browse the repository at this point in the history
Signed-off-by: drumato <[email protected]>
  • Loading branch information
Drumato committed Apr 11, 2024
1 parent bb64faa commit 37858fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 7 additions & 2 deletions convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 3 additions & 2 deletions webp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 37858fa

Please sign in to comment.