Module: ImageProcessing::Pura

Extended by:
Pura::Processing::Chainable
Defined in:
lib/image_processing/pura.rb

Defined Under Namespace

Classes: Processor

Class Method Summary collapse

Class Method Details

.valid_image?(file) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/image_processing/pura.rb', line 11

def self.valid_image?(file)
  path = file.respond_to?(:path) ? file.path : file.to_s
  data = File.binread(path, 8)
  format = ::Pura::Image::Processor.detect_format(data)
  return false unless format

  ::Pura::Image::Processor.load(path)
  true
rescue StandardError
  false
end