mirror of
https://github.com/jehiah/TrafficSpeed.git
synced 2025-10-01 06:32:17 +08:00
21 lines
321 B
Go
21 lines
321 B
Go
package project
|
|
|
|
import (
|
|
"image"
|
|
"image/png"
|
|
"log"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func (p *Project) SaveImage(i image.Image, name string) error {
|
|
fname := filepath.Join(p.Dir, name)
|
|
log.Printf("creating %s", fname)
|
|
f, err := os.Create(fname)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer f.Close()
|
|
return png.Encode(f, i)
|
|
}
|