diff --git a/activestorage/lib/active_storage/analyzer/image_analyzer/vips.rb b/activestorage/lib/active_storage/analyzer/image_analyzer/vips.rb index 44f15b73d0..cb4a6c2e07 100644 --- a/activestorage/lib/active_storage/analyzer/image_analyzer/vips.rb +++ b/activestorage/lib/active_storage/analyzer/image_analyzer/vips.rb @@ -19,13 +19,16 @@ def read_image download_blob_to_tempfile do |file| image = instrument("vips") do + # ruby-vips will raise Vips::Error if it can't find an appropriate loader for the file ::Vips::Image.new_from_file(file.path, access: :sequential) + rescue ::Vips::Error + logger.info "Skipping image analysis because Vips doesn't support the file" + nil end - if valid_image?(image) + if image yield image else - logger.info "Skipping image analysis because Vips doesn't support the file" {} end rescue ::Vips::Error => error @@ -40,12 +43,5 @@ def rotated_image?(image) rescue ::Vips::Error false end - - def valid_image?(image) - image.avg - true - rescue ::Vips::Error - false - end end end