Module: ImageValidator
Instance Method Summary collapse
Instance Method Details
#valid?(file) ⇒ Boolean
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/image_validator.rb', line 4 def valid?(file) file = thing_to_io(file) check_image_magick_is_available IO.popen("identify - >/dev/null 2>&1", "w") do |identify| some_content_has_been_read = false while blk = file.read(1024**2) identify << blk some_content_has_been_read = true if blk != "" end return false unless some_content_has_been_read end $?.success? end |