MCPcopy
hub / github.com/filebrowser/filebrowser / calculateImageResolution

Function calculateImageResolution

files/file.go:289–309  ·  view source on GitHub ↗
(fSys afero.Fs, filePath string)

Source from the content-addressed store, hash-verified

287}
288
289func 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
311func (i *FileInfo) readFirstBytes() []byte {
312 reader, err := i.Fs.Open(i.Path)

Callers 2

detectTypeMethod · 0.85
readListingMethod · 0.85

Calls 2

CloseMethod · 0.65
OpenMethod · 0.45

Tested by

no test coverage detected