Skip to content

Commit 13a1dd8

Browse files
committed
update: RAW 缩略图支持镜像方向。
1 parent f4aa9d2 commit 13a1dd8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pkg/thumb/libraw.go

+20
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ func rotateImg(filePath string, orientation int) error {
134134
img = rotate90(rotate90(img))
135135
case 6:
136136
img = rotate90(rotate90(rotate90(img)))
137+
case 2:
138+
img = mirrorImg(img)
139+
case 7:
140+
img = rotate90(mirrorImg(img))
141+
case 4:
142+
img = rotate90(rotate90(mirrorImg(img)))
143+
case 5:
144+
img = rotate90(rotate90(rotate90(mirrorImg(img))))
137145
}
138146

139147
if err = resultImg.Truncate(0); err != nil {
@@ -252,6 +260,18 @@ func rotate90(img image.Image) image.Image {
252260
return newImg
253261
}
254262

263+
func mirrorImg(img image.Image) image.Image {
264+
bounds := img.Bounds()
265+
width, height := bounds.Dx(), bounds.Dy()
266+
newImg := image.NewRGBA(image.Rect(0, 0, width, height))
267+
for x := 0; x < width; x++ {
268+
for y := 0; y < height; y++ {
269+
newImg.Set(width-x-1, y, img.At(x, y))
270+
}
271+
}
272+
return newImg
273+
}
274+
255275
func (f *LibRawGenerator) Priority() int {
256276
return 250
257277
}

0 commit comments

Comments
 (0)