Class: NconvertThumbnailPageGenerator
- Inherits:
-
ThumbnailPageGenerator
- Object
- HtmlGenerator
- ThumbnailPageGenerator
- NconvertThumbnailPageGenerator
- Defined in:
- lib/piggy-core/nconvert_thumbsgen.rb
Overview
Generates an internet picture album. It’s a wrapper around the commandline tool nconvert. You’ll need to istall this to get nconvert_thumbsgen.rb work.
Constant Summary
Constants inherited from ThumbnailPageGenerator
ThumbnailPageGenerator::DownloadName, ThumbnailPageGenerator::HtmlExt, ThumbnailPageGenerator::JavaFxName, ThumbnailPageGenerator::SlideshowName
Instance Attribute Summary
Attributes inherited from ThumbnailPageGenerator
#client, #imageOutputPath, #indexName, #subDir
Instance Method Summary collapse
- #conversion_type_for(type) ⇒ Object
- #escape(path) ⇒ Object
- #os_path(rubyPath) ⇒ Object
- #resize_file(file_info, width, height, prefix) ⇒ Object
- #sharpen?(file_info) ⇒ Boolean
Methods inherited from ThumbnailPageGenerator
#add_preview, #back, #build_frame_page, #build_html_pages_for_images, #build_javafx_config, #build_slideshow_list, #build_thumbnail_page, #build_zip_file, #bytes_as_string, #common_head, #copy_style, #copy_template_files, #copy_templates, #create_subdir, #error, #frame_text, #generate, #get_backlink_string, #image_column, #image_name, #image_row, #image_table, #initialize, #insert_in_file, #is_piggy_file?, #main_index_path, #main_index_with_path, #main_stylesheet_url, #output_path, #replace_in_file, #sep, #set_files, #set_output_directory, #set_title, #slideshow_image, #style_source_dir, #sub_stylesheet_url, #update_navigation_frame, #update_slideshow_template, #write_file
Methods inherited from HtmlGenerator
#a, #add, #add_html, #add_item, #begin_tag, #body, #br, #center, #channel, #cr, #dd, #dec_depth, #description, #div, #dl, #dt, #end_tag, #escape_html, #format_tag, #frame, #frameset, #get_page, #h1, #h2, #h3, #head, #html, #img, #inc_depth, #language, #link, #meta, #new_frame, #new_rss, #new_transitional, #new_xml, #noframes, #norobots, #p, #quote, #reset, #span, #stylesheet, #table, #tag, #td, #title, #tr, #utf8
Constructor Details
This class inherits a constructor from ThumbnailPageGenerator
Instance Method Details
#conversion_type_for(type) ⇒ Object
40 41 42 |
# File 'lib/piggy-core/nconvert_thumbsgen.rb', line 40 def conversion_type_for(type) 'jpg' end |
#escape(path) ⇒ Object
18 19 20 |
# File 'lib/piggy-core/nconvert_thumbsgen.rb', line 18 def escape(path) WinShell.instance.escape(path) end |
#os_path(rubyPath) ⇒ Object
14 15 16 |
# File 'lib/piggy-core/nconvert_thumbsgen.rb', line 14 def os_path(rubyPath) WinShell.instance.os_path(rubyPath) end |
#resize_file(file_info, width, height, prefix) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/piggy-core/nconvert_thumbsgen.rb', line 26 def resize_file(file_info, width, height, prefix) filename = file_info.name nconvert_path = 'nconvert' format = '-out jpeg -q 90' mode = '-ratio -rtype linear -rflag decr' sharpen = sharpen?(file_info) ? '-sharpen 5' : '' files_arg_string = escape(filename) out = "-o #{escape(os_path(File.join(imageOutputPath, prefix + '%.jpg')))}" resize = '-resize ' + width.to_s + ' ' + height.to_s rotate = file_info.rotate? ? " -rotate #{file_info.rotation.to_s} " : '' command = "#{nconvert_path} #{format} #{mode} #{rotate} #{resize} #{sharpen} #{out} #{files_arg_string}" client.run_command(command, os_path(file_info.path)) end |
#sharpen?(file_info) ⇒ Boolean
22 23 24 |
# File 'lib/piggy-core/nconvert_thumbsgen.rb', line 22 def sharpen?(file_info) ['JPG', 'JPEG'].include?(file_info.extension.upcase) end |