(localFilePath string, maxImageMegapixel int, ext string, checker func(file io.Reader, ext string, maxImageMegapixel int) error)
| 66 | } |
| 67 | |
| 68 | func decodeAndCheckImageFile(localFilePath string, maxImageMegapixel int, ext string, |
| 69 | checker func(file io.Reader, ext string, maxImageMegapixel int) error) bool { |
| 70 | file, err := os.Open(localFilePath) |
| 71 | if err != nil { |
| 72 | log.Errorf("open file error: %v", err) |
| 73 | return false |
| 74 | } |
| 75 | defer func() { |
| 76 | _ = file.Close() |
| 77 | }() |
| 78 | |
| 79 | if err = checker(file, ext, maxImageMegapixel); err != nil { |
| 80 | log.Errorf("check image format error: %v", err) |
| 81 | return false |
| 82 | } |
| 83 | return true |
| 84 | } |
| 85 | |
| 86 | // formatSpecificConfigCheck decodes image config using a format-specific decoder |
| 87 | // based on the file extension. This avoids calling image.DecodeConfig() which |
no test coverage detected