diff --git a/writer/standard/image_option_api.go b/writer/standard/image_option_api.go index c1e6f95..8c9ae52 100644 --- a/writer/standard/image_option_api.go +++ b/writer/standard/image_option_api.go @@ -94,6 +94,7 @@ func WithLogoImageFileJPEG(f string) ImageOption { fmt.Printf("could not open file(%s), error=%v\n", f, err) return } + defer fd.Close() img, err := jpeg.Decode(fd) if err != nil { @@ -114,6 +115,7 @@ func WithLogoImageFilePNG(f string) ImageOption { fmt.Printf("Open file(%s) failed: %v\n", f, err) return } + defer fd.Close() img, err := png.Decode(fd) if err != nil { diff --git a/writer/standard/writer_test.go b/writer/standard/writer_test.go index 0486950..7ba0317 100644 --- a/writer/standard/writer_test.go +++ b/writer/standard/writer_test.go @@ -124,6 +124,8 @@ func hashFile(filename string) (string, error) { if err != nil { return "", err } + defer fd1.Close() + bytes, err := io.ReadAll(fd1) if err != nil { return "", err @@ -140,6 +142,7 @@ func statImage(filename string) (w, h int, err error) { if err != nil { return 0, 0, err } + defer fd.Close() img, err := png.Decode(fd) if err != nil {