Cleanup up imageio
This commit is contained in:
parent
536e5a7d54
commit
34d7ee3c27
1 changed files with 5 additions and 3 deletions
|
@ -5,7 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"path/filepath"
|
||||||
|
|
||||||
"image/color"
|
"image/color"
|
||||||
"image/jpeg"
|
"image/jpeg"
|
||||||
|
@ -75,14 +75,16 @@ func Write(filename string, width, height int, buffer []byte) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasSuffix(filename, ".png") {
|
switch filepath.Ext(filename) {
|
||||||
|
case ".png":
|
||||||
if err := png.Encode(f, image); err != nil {
|
if err := png.Encode(f, image); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if strings.HasSuffix(filename, ".jpg") || strings.HasSuffix(filename, ".jpeg") {
|
case ".jpg", ".jpeg":
|
||||||
if err := jpeg.Encode(f, image, nil); err != nil {
|
if err := jpeg.Encode(f, image, nil); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue