This commit is contained in:
jack77213 2020-03-02 19:36:37 +08:00
parent 9a21ef6a3d
commit 3225640d7d
Signed by: jack77213
GPG Key ID: CA81AA7BB873B9F1
1 changed files with 3 additions and 3 deletions

View File

@ -5,7 +5,7 @@ import (
"fmt"
"image"
"image/color"
"image/png"
"image/jpeg"
"log"
"os"
"strings"
@ -73,12 +73,12 @@ func corpImage(img image.Image, width int, level int, dirname string) {
rect := image.Rect(i, j, i+1000, j+1000)
imgOut := img.SubImage(rect)
imgOut = imaging.Paste(imaging.New(1000, 1000, color.NRGBA{0, 0, 0, 0}), imgOut, image.Pt(0, 0))
fileName := fmt.Sprintf("%s/%d/x%d_y%d.png", dirname, level, i/1000, j/1000)
fileName := fmt.Sprintf("%s/%d/x%d_y%d.jpg", dirname, level, i/1000, j/1000)
fileOut, err := os.Create(fileName)
if err != nil {
panic(err)
}
png.Encode(fileOut, imgOut)
jpeg.Encode(fileOut, imgOut, &jpeg.Options{})
fileOut.Close()
wg.Done()
}(&wg, i, j, img)