fix image

This commit is contained in:
Pete Matsyburka
2024-11-01 18:39:03 +02:00
parent 05647135bc
commit ff14caa9f7
2 changed files with 19 additions and 3 deletions
@@ -19,7 +19,6 @@ module Submissions
MAX_PAGE_ROTATE = 20
A4_SIZE = [595, 842].freeze
SUPPORTED_IMAGE_TYPES = ['image/png', 'image/jpeg'].freeze
TESTING_FOOTER = 'Testing Document - NOT LEGALLY BINDING'
@@ -273,7 +272,15 @@ module Submissions
attachments_data_cache[attachment.uuid] ||= attachment.download
image = Vips::Image.new_from_buffer(attachments_data_cache[attachment.uuid], '').autorot
image =
begin
Vips::Image.new_from_buffer(attachments_data_cache[attachment.uuid], '').autorot
rescue Vips::Error
next unless attachment.content_type.starts_with?('image/')
next if attachment.byte_size.zero?
raise
end
scale = [(area['w'] * width) / image.width,
(area['h'] * height) / image.height].min