Class: Despeck::Commands::Remove

Inherits:
Clamp::Command
  • Object
show all
Defined in:
lib/commands/remove.rb

Overview

Subcommand that removes watermarks from images & PDFs

Instance Method Summary collapse

Instance Method Details

#executeObject



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/commands/remove.rb', line 41

def execute
  Despeck.apply_logger_level(debug?)

  if input_file.end_with?('.pdf')
    origin_images = PdfTools.pdf_to_images(input_file)
    images = origin_images.map do |image|
      remove_watermark_from_image(image, nil)
    end
    PdfTools.images_to_pdf(images, output_file, origin_images)
  else
    remove_watermark_from_image(input_file, output_file)
  end
end