From 13a1dd851268de10542f5604fceb23ae8970c58b Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 30 Jul 2024 23:42:33 +0800 Subject: [PATCH] =?UTF-8?q?update:=20RAW=20=E7=BC=A9=E7=95=A5=E5=9B=BE?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=95=9C=E5=83=8F=E6=96=B9=E5=90=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/thumb/libraw.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/thumb/libraw.go b/pkg/thumb/libraw.go index 6f337020..089e5f80 100644 --- a/pkg/thumb/libraw.go +++ b/pkg/thumb/libraw.go @@ -134,6 +134,14 @@ func rotateImg(filePath string, orientation int) error { img = rotate90(rotate90(img)) case 6: img = rotate90(rotate90(rotate90(img))) + case 2: + img = mirrorImg(img) + case 7: + img = rotate90(mirrorImg(img)) + case 4: + img = rotate90(rotate90(mirrorImg(img))) + case 5: + img = rotate90(rotate90(rotate90(mirrorImg(img)))) } if err = resultImg.Truncate(0); err != nil { @@ -252,6 +260,18 @@ func rotate90(img image.Image) image.Image { return newImg } +func mirrorImg(img image.Image) image.Image { + bounds := img.Bounds() + width, height := bounds.Dx(), bounds.Dy() + newImg := image.NewRGBA(image.Rect(0, 0, width, height)) + for x := 0; x < width; x++ { + for y := 0; y < height; y++ { + newImg.Set(width-x-1, y, img.At(x, y)) + } + } + return newImg +} + func (f *LibRawGenerator) Priority() int { return 250 }