-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgallery.rb
More file actions
executable file
·30 lines (24 loc) · 819 Bytes
/
gallery.rb
File metadata and controls
executable file
·30 lines (24 loc) · 819 Bytes
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
#!/usr/bin/env ruby
require 'yaml'
require 'RMagick'
include Magick
#load config file
config=YAML.load_file "config.yml"
title = config["title"]
in_dir = config["input"]
out_dir = config["output"]
author = config["author"]
thumbs_dir = out_dir + "/" + "thumbs"
#setup directories
Dir::mkdir(out_dir) unless File.exists?(out_dir)
Dir::mkdir(thumbs_dir) unless File.exists?(thumbs_dir)
Dir.glob("#{in_dir}/*.jpg") do |image| #search directory for jpg files
image_name = File.basename(image)
fullsize = ImageList.new("#{image}")
fullsize.write("#{out_dir}/#{image_name}")
fullsize.change_geometry!('150x150') { |cols, rows, img|
thumb = img.resize(cols, rows)
thumb.write("#{out_dir}/thumbs/th_#{image_name}")
}
puts "\<a href=\"#{image_name}\"\>\<img src=\"thumbs/th_#{image_name}\" /\>\</a\>"
end