adjust image load

This commit is contained in:
Pete Matsyburka
2026-05-21 15:38:16 +03:00
parent 9e4da5948b
commit 07841722ac
9 changed files with 42 additions and 51 deletions
+15
View File
@@ -1,8 +1,23 @@
# frozen_string_literal: true
module ImageUtils
ICO_REGEXP = %r{\Aimage/(?:x-icon|vnd\.microsoft\.icon)\z}
BMP_REGEXP = %r{\Aimage/(?:bmp|x-bmp|x-ms-bmp)\z}
module_function
def load_vips(data, content_type: nil)
content_type ||= Marcel::MimeType.for(data)
if ICO_REGEXP.match?(content_type)
LoadIco.call(data)
elsif BMP_REGEXP.match?(content_type)
LoadBmp.call(data)
else
Vips::Image.new_from_buffer(data, '')
end
end
def blank?(image)
stats = image.stats