From 9ceca2ba1389eef8c06774bba59e49165881355f Mon Sep 17 00:00:00 2001 From: Rob Kaufman Date: Thu, 21 Sep 2023 00:14:17 -0700 Subject: [PATCH 1/2] make sure layers are flattened to fix pdf tripple issue --- .../derivatives/processors/image_decorator.rb | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lib/hydra/derivatives/processors/image_decorator.rb diff --git a/lib/hydra/derivatives/processors/image_decorator.rb b/lib/hydra/derivatives/processors/image_decorator.rb new file mode 100644 index 000000000..f9f4145af --- /dev/null +++ b/lib/hydra/derivatives/processors/image_decorator.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +# Fix PDF tripple issue + +module Hydra + module Derivatives + module Processors + module ImageDecorator + protected + + # When resizing images, it is necessary to flatten any layers, otherwise the background + # may be completely black. This happens especially with PDFs. See #110 + def create_resized_image + create_image do |xfrm| + if size + xfrm.combine_options do |i| + i.flatten + i.resize(size) + end + end + end + end + end + end + end +end + +::Hydra::Derivatives::Processors::Image.prepend(Hydra::Derivatives::Processors::ImageDecorator) From 485dcec8e93ba9f3c526bc4cb938d2adc682f158 Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Thu, 21 Sep 2023 08:52:40 -0700 Subject: [PATCH 2/2] Update lib/hydra/derivatives/processors/image_decorator.rb Co-authored-by: Alisha Evans --- lib/hydra/derivatives/processors/image_decorator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hydra/derivatives/processors/image_decorator.rb b/lib/hydra/derivatives/processors/image_decorator.rb index f9f4145af..6c4d610af 100644 --- a/lib/hydra/derivatives/processors/image_decorator.rb +++ b/lib/hydra/derivatives/processors/image_decorator.rb @@ -9,7 +9,7 @@ module ImageDecorator protected # When resizing images, it is necessary to flatten any layers, otherwise the background - # may be completely black. This happens especially with PDFs. See #110 + # may be completely black. This happens especially with PDFs. See https://github.com/samvera/hydra-derivatives/issues/110 def create_resized_image create_image do |xfrm| if size