(fSys afero.Fs, filePath string)
| 287 | } |
| 288 | |
| 289 | func calculateImageResolution(fSys afero.Fs, filePath string) (*ImageResolution, error) { |
| 290 | file, err := fSys.Open(filePath) |
| 291 | if err != nil { |
| 292 | return nil, err |
| 293 | } |
| 294 | defer func() { |
| 295 | if cErr := file.Close(); cErr != nil { |
| 296 | log.Printf("Failed to close file: %v", cErr) |
| 297 | } |
| 298 | }() |
| 299 | |
| 300 | config, _, err := image.DecodeConfig(file) |
| 301 | if err != nil { |
| 302 | return nil, err |
| 303 | } |
| 304 | |
| 305 | return &ImageResolution{ |
| 306 | Width: config.Width, |
| 307 | Height: config.Height, |
| 308 | }, nil |
| 309 | } |
| 310 | |
| 311 | func (i *FileInfo) readFirstBytes() []byte { |
| 312 | reader, err := i.Fs.Open(i.Path) |
no test coverage detected