From e6845cd94db3d7925959df317b917034af48c89e Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Thu, 24 Oct 2024 10:13:34 +0200 Subject: [PATCH 1/3] fix(image processing): handle case of blob without attachments --- app/models/concerns/attachment_image_processor_concern.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/attachment_image_processor_concern.rb b/app/models/concerns/attachment_image_processor_concern.rb index 5047e1fe7..aee9fa9d6 100644 --- a/app/models/concerns/attachment_image_processor_concern.rb +++ b/app/models/concerns/attachment_image_processor_concern.rb @@ -18,7 +18,7 @@ module AttachmentImageProcessorConcern def process_image return if blob.nil? - return if blob.attachments.size > 1 + return if blob.attachments.size != 1 return if blob.attachments.last.record_type == "Export" ImageProcessorJob.perform_later(blob) From 4dc13cc56c046139d0bba2004393a9b8e2adbb92 Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Thu, 24 Oct 2024 11:50:41 +0200 Subject: [PATCH 2/3] fix(image processing): process only authorized image and pdf types --- app/models/concerns/attachment_image_processor_concern.rb | 1 + config/initializers/authorized_content_types.rb | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/attachment_image_processor_concern.rb b/app/models/concerns/attachment_image_processor_concern.rb index aee9fa9d6..cd0e3ff65 100644 --- a/app/models/concerns/attachment_image_processor_concern.rb +++ b/app/models/concerns/attachment_image_processor_concern.rb @@ -20,6 +20,7 @@ module AttachmentImageProcessorConcern return if blob.nil? return if blob.attachments.size != 1 return if blob.attachments.last.record_type == "Export" + return if !blob.content_type.in?(PROCESSABLE_TYPES) ImageProcessorJob.perform_later(blob) end diff --git a/config/initializers/authorized_content_types.rb b/config/initializers/authorized_content_types.rb index 2a9a38d78..497757957 100644 --- a/config/initializers/authorized_content_types.rb +++ b/config/initializers/authorized_content_types.rb @@ -21,7 +21,9 @@ RARE_IMAGE_TYPES = [ 'image/tiff' # multimedia x 3985 ] -AUTHORIZED_CONTENT_TYPES = AUTHORIZED_IMAGE_TYPES + AUTHORIZED_PDF_TYPES + [ +PROCESSABLE_TYPES = AUTHORIZED_IMAGE_TYPES + AUTHORIZED_PDF_TYPES + +AUTHORIZED_CONTENT_TYPES = PROCESSABLE_TYPES + [ # multimedia 'video/mp4', # multimedia x 2075 'video/quicktime', # multimedia x 486 From 93fcd4ad49aeda6ea10d691d28f45c5ef97f3af7 Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Thu, 24 Oct 2024 18:13:00 +0200 Subject: [PATCH 3/3] fix(image processing): do not uninterlace if no png path --- app/services/uninterlace_service.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/services/uninterlace_service.rb b/app/services/uninterlace_service.rb index d4cef3aaf..0ec100e38 100644 --- a/app/services/uninterlace_service.rb +++ b/app/services/uninterlace_service.rb @@ -17,6 +17,7 @@ class UninterlaceService end def interlaced?(png_path) + return false if png_path.blank? png = MiniMagick::Image.open(png_path) png.data["interlace"] != "None" end