Class: BrandLogo::FastimageAnalyzer

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
ImageAnalyzer
Defined in:
lib/brand_logo/image_analyzer.rb

Overview

Concrete implementation using the FastImage gem. Avoids downloading the full image by parsing only the header bytes.

Instance Method Summary collapse

Instance Method Details

#dimensions(url) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/brand_logo/image_analyzer.rb', line 27

def dimensions(url)
  result = FastImage.size(url)
  return { width: nil, height: nil } unless result

  { width: result[0], height: result[1] }
rescue StandardError
  { width: nil, height: nil }
end