From 5dd59f4f7c1da1e67bfe32519241dd612f088e0a Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Wed, 18 Sep 2024 13:48:52 +0300 Subject: [PATCH] optimize image --- lib/templates/process_document.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/templates/process_document.rb b/lib/templates/process_document.rb index 8bbd8b09..1ac63a6e 100644 --- a/lib/templates/process_document.rb +++ b/lib/templates/process_document.rb @@ -44,7 +44,7 @@ module Templates bitdepth = 2**image.stats.to_a[1..3].pluck(2).uniq.size io = StringIO.new(image.write_to_buffer(FORMAT, compression: 7, filter: 0, bitdepth:, - palette: true, Q: Q, dither: 0)) + palette: true, Q: bitdepth == 8 ? Q : 5, dither: 0)) ActiveStorage::Attachment.create!( blob: ActiveStorage::Blob.create_and_upload!( @@ -100,7 +100,7 @@ module Templates bitdepth = 2**page.stats.to_a[1..3].pluck(2).uniq.size io = StringIO.new(page.write_to_buffer(FORMAT, compression: 7, filter: 0, bitdepth:, - palette: true, Q: Q, dither: 0)) + palette: true, Q: bitdepth == 8 ? Q : 5, dither: 0)) blob = ActiveStorage::Blob.new( filename: "#{page_number}#{FORMAT}",