Class: VCSRuby::ContactSheet
- Inherits:
-
Object
- Object
- VCSRuby::ContactSheet
- Defined in:
- lib/contact_sheet.rb
Instance Attribute Summary collapse
-
#aspect_ratio ⇒ Object
Returns the value of attribute aspect_ratio.
-
#format ⇒ Object
Returns the value of attribute format.
-
#from ⇒ Object
Returns the value of attribute from.
-
#highlight ⇒ Object
Returns the value of attribute highlight.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#polaroid ⇒ Object
Returns the value of attribute polaroid.
-
#signature ⇒ Object
Returns the value of attribute signature.
-
#softshadow ⇒ Object
Returns the value of attribute softshadow.
-
#thumbnail_height ⇒ Object
Returns the value of attribute thumbnail_height.
-
#thumbnail_width ⇒ Object
Returns the value of attribute thumbnail_width.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#title ⇒ Object
Returns the value of attribute title.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #build ⇒ Object
- #columns ⇒ Object
- #filename ⇒ Object
- #full_path ⇒ Object
-
#initialize(video, capturer) ⇒ ContactSheet
constructor
A new instance of ContactSheet.
- #initialize_filename(override = nil) ⇒ Object
- #initialize_geometry(rows, columns, interval) ⇒ Object
- #interval ⇒ Object
- #number_of_caps ⇒ Object
- #rows ⇒ Object
Constructor Details
#initialize(video, capturer) ⇒ ContactSheet
Returns a new instance of ContactSheet.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/contact_sheet.rb', line 16 def initialize video, capturer @video = video @capturer = capturer @signature = "Created by Video Contact Sheet Ruby" initialize_filename if Configuration.instance.verbose? puts "Processing #{File.basename(video.full_path)}..." end return unless @video.valid? detect_video_properties @from = TimeIndex.new 0 @to = @video.info.duration @timestamp = Configuration.instance. @softshadow = Configuration.instance.softshadow @polaroid = Configuration.instance.polaroid @tempdir = Dir.mktmpdir ObjectSpace.define_finalizer(self, self.class.finalize(@tempdir) ) initialize_geometry(Configuration.instance.rows, Configuration.instance.columns, Configuration.instance.interval) end |
Instance Attribute Details
#aspect_ratio ⇒ Object
Returns the value of attribute aspect_ratio.
13 14 15 |
# File 'lib/contact_sheet.rb', line 13 def aspect_ratio @aspect_ratio end |
#format ⇒ Object
Returns the value of attribute format.
13 14 15 |
# File 'lib/contact_sheet.rb', line 13 def format @format end |
#from ⇒ Object
Returns the value of attribute from.
14 15 16 |
# File 'lib/contact_sheet.rb', line 14 def from @from end |
#highlight ⇒ Object
Returns the value of attribute highlight.
11 12 13 |
# File 'lib/contact_sheet.rb', line 11 def highlight @highlight end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
14 15 16 |
# File 'lib/contact_sheet.rb', line 14 def length @length end |
#polaroid ⇒ Object
Returns the value of attribute polaroid.
12 13 14 |
# File 'lib/contact_sheet.rb', line 12 def polaroid @polaroid end |
#signature ⇒ Object
Returns the value of attribute signature.
11 12 13 |
# File 'lib/contact_sheet.rb', line 11 def signature @signature end |
#softshadow ⇒ Object
Returns the value of attribute softshadow.
12 13 14 |
# File 'lib/contact_sheet.rb', line 12 def softshadow @softshadow end |
#thumbnail_height ⇒ Object
Returns the value of attribute thumbnail_height.
13 14 15 |
# File 'lib/contact_sheet.rb', line 13 def thumbnail_height @thumbnail_height end |
#thumbnail_width ⇒ Object
Returns the value of attribute thumbnail_width.
13 14 15 |
# File 'lib/contact_sheet.rb', line 13 def thumbnail_width @thumbnail_width end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
12 13 14 |
# File 'lib/contact_sheet.rb', line 12 def @timestamp end |
#title ⇒ Object
Returns the value of attribute title.
11 12 13 |
# File 'lib/contact_sheet.rb', line 11 def title @title end |
#to ⇒ Object
Returns the value of attribute to.
14 15 16 |
# File 'lib/contact_sheet.rb', line 14 def to @to end |
Instance Method Details
#build ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/contact_sheet.rb', line 126 def build if (@video.info.duration.total_seconds < 1.0) puts "Video is shorter than 1 sec" else initialize_filters initialize_thumbnails capture_thumbnails puts "Composing standard contact sheet..." unless Configuration.instance.quiet? montage = splice_montage(montage_thumbs) image = MiniMagick::Image.open(montage) puts "Adding header and footer..." unless Configuration.instance.quiet? final = image puts "Done. Output wrote to '#{filename}'" unless Configuration.instance.quiet? FileUtils.mv(final, full_path) end end |
#columns ⇒ Object
75 76 77 |
# File 'lib/contact_sheet.rb', line 75 def columns @columns end |
#filename ⇒ Object
59 60 61 |
# File 'lib/contact_sheet.rb', line 59 def filename "#{@out_filename}#{@format}" end |
#full_path ⇒ Object
67 68 69 |
# File 'lib/contact_sheet.rb', line 67 def full_path File.join(@out_path, filename) end |
#initialize_filename(override = nil) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/contact_sheet.rb', line 44 def initialize_filename override = nil @out_path = File.dirname(@video.full_path) @out_filename = File.basename(override || @video.full_path,'.*') extension = override ? File.extname(override) : '' @format = extension.length > 0 ? extension : '.png' end |
#initialize_geometry(rows, columns, interval) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/contact_sheet.rb', line 52 def initialize_geometry(rows, columns, interval) @has_interval = !!interval @rows = rows @columns = columns @interval = interval end |
#interval ⇒ Object
79 80 81 |
# File 'lib/contact_sheet.rb', line 79 def interval @interval || (@to - @from) / (number_of_caps) end |
#number_of_caps ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/contact_sheet.rb', line 83 def number_of_caps if @has_interval (@to - @from) / @interval else if @rows && @columns @rows * @columns else raise "you need at least 2 parameters from columns, rows and interval" end end end |
#rows ⇒ Object
71 72 73 |
# File 'lib/contact_sheet.rb', line 71 def rows @rows end |