cmd/gopngquant: allow setting -Speed parameter
This commit is contained in:
parent
67b09086b4
commit
2d513a1a66
@ -52,7 +52,7 @@ func Rgb8PaletteToGoImage(w, h int, rgb8data []byte, pal color.Palette) image.Im
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func Crush(sourcefile, destfile string) error {
|
func Crush(sourcefile, destfile string, speed int) error {
|
||||||
|
|
||||||
fh, err := os.OpenFile(sourcefile, os.O_RDONLY, 0444)
|
fh, err := os.OpenFile(sourcefile, os.O_RDONLY, 0444)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -74,6 +74,11 @@ func Crush(sourcefile, destfile string) error {
|
|||||||
}
|
}
|
||||||
defer attr.Release()
|
defer attr.Release()
|
||||||
|
|
||||||
|
err = attr.SetSpeed(speed)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("SetSpeed: %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
rgba32data := GoImageToRgba32(img)
|
rgba32data := GoImageToRgba32(img)
|
||||||
|
|
||||||
iqm, err := imagequant.NewImage(attr, string(rgba32data), width, height, 0)
|
iqm, err := imagequant.NewImage(attr, string(rgba32data), width, height, 0)
|
||||||
@ -116,6 +121,7 @@ func main() {
|
|||||||
ShouldDisplayVersion := flag.Bool("Version", false, "")
|
ShouldDisplayVersion := flag.Bool("Version", false, "")
|
||||||
Infile := flag.String("In", "", "Input filename")
|
Infile := flag.String("In", "", "Input filename")
|
||||||
Outfile := flag.String("Out", "", "Output filename")
|
Outfile := flag.String("Out", "", "Output filename")
|
||||||
|
Speed := flag.Int("Speed", 3, "Speed (1 slowest, 10 fastest)")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
@ -124,7 +130,7 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := Crush(*Infile, *Outfile)
|
err := Crush(*Infile, *Outfile, *Speed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
fmt.Println(err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user