Class: Libis::Format::Cli::Convert

Inherits:
SubCommand show all
Defined in:
lib/libis/format/cli/convert.rb

Constant Summary collapse

DEFAULT_CONFIG =
{
    scale: '100%',
    resize: '100%',
    wm_tiles: 4,
    wm_resize: 1.0,
    wm_gap: 0.2,
    wm_rotation: 30,
    wm_opacity: 0.1,
    wm_gravity: 'center',
    wm_composition: 'modulate'
}
STRING_CONFIG =
{
    page: 'Page number to select for multipage documents',
    quiet: 'suppress all warning messages. Error messages are still reported',
    scale: 'minify / magnify the image with pixel block averaging and pixel replication, respectively',
    resize: 'Resize the image',
    resample: 'Resize the image so that its rendered size remains the same as the original at the specified target resolution',
    flatten: 'Create a canvas the size of the first images virtual canvas using the current -background color, and -compose each image in turn onto that canvas. Images falling outside that canvas is clipped',
    delete_date: 'Remove modified date and created date metadata from the target image',
    colorspace: 'Set the image colorspace',
    profile: 'Specify color profile used for the image',
    wm_text: 'Create watermark with given text',
    wm_file: 'Create watermark from given file',
    wm_tiles: 'Number of tiles of the watermark to distribute over the image. 0: no tiling, 1: watermark image scaled to fit image, n>1: at least n tiles horizontally/vertically, n<0: tile without recaling',
    wm_resize: 'Resize the watermark image (fraction 0.0 - 1.0)',
    wm_gap: 'Leave n % of whitespace between the watermark images. Similar effect can be achieved with wm_resize',
    wm_rotation: 'Rotate the watermark text n degrees counterclockwise (0-360)',
    wm_opacity: 'Opacity of the watermark (fraction 0.0 - 1.0)',
    wm_gravity: 'Center point of the watermark overlay',
    wm_composition: 'Set the type of image composition'
}

Instance Attribute Summary

Attributes included from PromptHelper

#pastel, #prompt

Instance Method Summary collapse

Methods inherited from SubCommand

banner, subcommand_prefix

Methods included from PromptHelper

#initialize

Instance Method Details

#auto(source_file, target_file) ⇒ Object



77
78
79
80
81
82
# File 'lib/libis/format/cli/convert.rb', line 77

def auto(source_file, target_file)
  options_file = options[:options]
  opts = check_input(source_file, target_file, options_file)
  output, converter = do_convert(source_file, target_file, opts)
  prompt.ok "Output file '#{output}' created with converter #{converter}."
end

#image(source_file, target_file) ⇒ Object



116
117
118
119
120
# File 'lib/libis/format/cli/convert.rb', line 116

def image(source_file, target_file)
  check_input(source_file, target_file)
  convert_image(source_file, target_file)
  prompt.ok "Output file '#{target_file}' created with image converter."
end