mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-11-18 17:17:31 +00:00
Add JPEG encoder
This commit is contained in:
parent
a70a5a4d1a
commit
0454e29e34
26
bin/stitch/export-jpeg.go
Normal file
26
bin/stitch/export-jpeg.go
Normal file
@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"image/jpeg"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
func exportJPEG(stitchedImage *StitchedImage) error {
|
||||
log.Printf("Creating output file %q.", *flagOutputPath)
|
||||
f, err := os.Create(*flagOutputPath)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
options := &jpeg.Options{
|
||||
Quality: 80,
|
||||
}
|
||||
|
||||
if err := jpeg.Encode(f, stitchedImage, options); err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -270,6 +270,8 @@ func main() {
|
||||
switch fileExtension {
|
||||
case ".png":
|
||||
exportPNG(stitchedImage)
|
||||
case ".jpg", ".jpeg":
|
||||
exportJPEG(stitchedImage)
|
||||
default:
|
||||
log.Panicf("Unknown output format %q.", fileExtension)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user