update: RAW 缩略图支持镜像方向。

This commit is contained in:
sam 2024-07-30 23:42:33 +08:00
parent f4aa9d2976
commit 13a1dd8512

View file

@ -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
}