File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed
activestorage/lib/active_storage/analyzer/image_analyzer Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -19,13 +19,16 @@ def read_image
19
19
20
20
download_blob_to_tempfile do |file |
21
21
image = instrument ( "vips" ) do
22
+ # ruby-vips will raise Vips::Error if it can't find an appropriate loader for the file
22
23
::Vips ::Image . new_from_file ( file . path , access : :sequential )
24
+ rescue ::Vips ::Error
25
+ logger . info "Skipping image analysis because Vips doesn't support the file"
26
+ nil
23
27
end
24
28
25
- if valid_image? ( image )
29
+ if image
26
30
yield image
27
31
else
28
- logger . info "Skipping image analysis because Vips doesn't support the file"
29
32
{ }
30
33
end
31
34
rescue ::Vips ::Error => error
@@ -40,12 +43,5 @@ def rotated_image?(image)
40
43
rescue ::Vips ::Error
41
44
false
42
45
end
43
-
44
- def valid_image? ( image )
45
- image . avg
46
- true
47
- rescue ::Vips ::Error
48
- false
49
- end
50
46
end
51
47
end
You can’t perform that action at this time.
0 commit comments