refactor(watermark): small text based watermarked to increase document visibility

This commit is contained in:
Colin Darie 2023-09-07 18:10:26 +02:00
parent 2f5310a470
commit 201b31bf36
No known key found for this signature in database
GPG key ID: 8C76CADD40253590
7 changed files with 172 additions and 66 deletions

View file

@ -22,4 +22,32 @@ namespace :pjs do
blobs.in_batches { |batch| batch.ids.each { |id| PjsMigrationJob.perform_later(id) } }
end
desc "Watermark demo. Usage: noglob rake pjs:watermark_demo[tmp/carte-identite-demo-1.jpg]"
task :watermark_demo, [:file_path] => :environment do |_t, args|
file = Pathname.new(args[:file_path])
output_file = Rails.root.join('tmp', "#{file.basename(file.extname)}_watermarked#{file.extname}")
processed = WatermarkService.new.process(file, output_file)
if processed
rake_puts "Watermarked: #{processed}"
else
rake_puts "File #{file} not watermarked. Read application log for more information"
end
end
desc "Watermark demo all defined demo files. Usage: noglob rake pjs:watermark_demo_all"
task :watermark_demo_all => :environment do
# You must have these filenames in tmp/ to run this demo (download ID cards specimens)
filenames = [
"carte-identite-demo-1.jpg", "carte-identite-demo-2.jpg", "carte-identite-demo-3.png", "carte-identite-demo-4.jpg",
"carte-identite-demo-5.jpg", "passeport-1.jpg", "passeport-2.jpg"
]
filenames.each do |file|
Rake::Task["pjs:watermark_demo"].invoke("tmp/#{file}")
Rake::Task["pjs:watermark_demo"].reenable
end
end
end