-
Notifications
You must be signed in to change notification settings - Fork 0
/
keynote_dump.rb
executable file
·43 lines (33 loc) · 1.09 KB
/
keynote_dump.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
#!/usr/bin/env ruby
STDOUT.sync = true
require "rubygems"
require "bundler/setup"
Bundler.require(:default)
Dir[File.dirname(__FILE__) + '/lib/*.rb'].each {|file| require file }
shortname, slide_template, page_template, aspect_ratio = ARGV
unless shortname && slide_template && page_template
puts "Usage: keynote_dump.rb shortname_for_slides slide_template_file page_template_file [imagemagick_resize_ratio]"
puts "Optional resize ratio should be of the format (eg) 300x225"
exit
end
puts "Exporting notes from Keynote"
keynote = KeynoteProcessor.new('Keynote')
keynote.ingest!
kt = SlideTemplater.new(File.read(slide_template), File.read(page_template), shortname)
File.open("#{shortname}/#{shortname}.html", "w") do |f|
f << kt.process_keynote(keynote)
end
if aspect_ratio
begin
puts "Resizing all slides in #{shortname}/img"
Dir.glob("#{shortname}/img/*.png") do |file|
image = MiniMagick::Image.open(file)
image.resize aspect_ratio
image.write(file)
print "."
end
puts
rescue
puts "Invalid resizing format. Slides will not be resized"
end
end