Class: RmagickThumbnailPageGenerator

Inherits:
ThumbnailPageGenerator show all
Defined in:
lib/piggy-core/rmagick_thumbnail_page_generator.rb

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

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, #conversion_type_for, #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

#resize_file(file_info, widescreen_width, width, height, prefix) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/piggy-core/rmagick_thumbnail_page_generator.rb', line 5

def resize_file(file_info, widescreen_width, width, height, prefix)
  img = Magick::Image.read(file_info.name_with_path)[0]
  if(file_info.rotate?)
    img = img.rotate!(file_info.rotation)
  end
  img_width = img.columns.to_f
  img_height = img.rows.to_f
  used_width = (img_height > 0 and img_width/img_height > 1.6) ? widescreen_width : width
  scale_x = img_width > used_width ? used_width/img_width : 1
  scale_y = img_height > height ? height/img_height : 1
  scale = scale_x < scale_y ? scale_x : scale_y
  img = img.resize!(scale)
  img.write(File.join(imageOutputPath,prefix + file_info.name))
end