Skip to content

Commit

Permalink
Merge pull request #19 from qt-luigi/addClose
Browse files Browse the repository at this point in the history
Add file close call to loadImage()/saveImage()
  • Loading branch information
disintegration authored Mar 22, 2019
2 parents e7b6d79 + c07d7f3 commit 5c2e6f4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func loadImage(filename string) image.Image {
if err != nil {
log.Fatalf("os.Open failed: %v", err)
}
defer f.Close()
img, _, err := image.Decode(f)
if err != nil {
log.Fatalf("image.Decode failed: %v", err)
Expand All @@ -245,6 +246,7 @@ func saveImage(filename string, img image.Image) {
if err != nil {
log.Fatalf("os.Create failed: %v", err)
}
defer f.Close()
err = png.Encode(f, img)
if err != nil {
log.Fatalf("png.Encode failed: %v", err)
Expand Down

0 comments on commit 5c2e6f4

Please sign in to comment.