allow to disable stamp logo

This commit is contained in:
Pete Matsyburka
2024-03-14 14:09:43 +02:00
parent a963ef53d3
commit 0171b0c2dd
4 changed files with 38 additions and 9 deletions
+9 -4
View File
@@ -13,8 +13,8 @@ module Submitters
module_function
def call(submitter)
image = generate_stamp_image(submitter)
def call(submitter, with_logo: true)
image = generate_stamp_image(submitter, with_logo:)
image_data = image.write_to_buffer('.png')
@@ -30,8 +30,13 @@ module Submitters
)
end
def generate_stamp_image(submitter)
logo = Vips::Image.new_from_buffer(load_logo(submitter).read, '')
def generate_stamp_image(submitter, with_logo: true)
logo =
if with_logo
Vips::Image.new_from_buffer(load_logo(submitter).read, '')
else
Vips::Image.new_from_buffer(TRANSPARENT_PIXEL, '').resize(WIDTH)
end
logo = logo.resize([WIDTH / logo.width.to_f, HEIGHT / logo.height.to_f].min)
+3 -1
View File
@@ -78,7 +78,9 @@ module Submitters
next if field['submitter_uuid'] != submitter.uuid
if field['type'] == 'stamp'
acc[field['uuid']] ||= Submitters::CreateStampAttachment.call(submitter).uuid
acc[field['uuid']] ||=
Submitters::CreateStampAttachment.call(submitter,
with_logo: field.dig('preferences', 'with_logo') != false).uuid
next
end