-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
64 lines (50 loc) · 1.6 KB
/
Rakefile
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
require "rubygems"
require 'rake'
require 'yaml'
require 'time'
require 'open-uri'
require 'RMagick'
require "digest/md5"
desc "Launch preview environment"
task :preview do
system "jekyll serve --watch --drafts"
end # task :preview
desc "Generate icons based on your gravatar"
task :icons, [:email] do |t, args|
author_email = args[:email]
gravatar_id = Digest::MD5.hexdigest(author_email)
base_url = "http://www.gravatar.com/avatar/#{gravatar_id}?s=150"
origin = "origin.png"
File.delete origin if File.exist? origin
puts "Downloading base image file from gravatar..."
open(origin, 'wb') do |file|
file << open(base_url).read
end
name_pre = "apple-touch-icon-%dx%d-precomposed.png"
FileList["*apple-touch-ico*.png"].each do |img|
File.delete img
end
[180, 152, 120, 76, 57].each do |size|
puts "Creating #{name_pre} icon..." % [size, size]
Magick::Image::read(origin).first.resize(size, size).
write(name_pre % [size, size])
end
system("cp " + name_pre % [180,180] + " apple-touch-icon-precomposed.png")
system("cp " + name_pre % [180,180] + " apple-touch-icon.png")
name_pre = "touch-icon-%dx%d.png"
FileList["touch-ico*.png"].each do |img|
File.delete img
end
[192].each do |size|
puts "Creating #{name_pre} icon..." % [size, size]
Magick::Image::read(origin).first.resize(size, size).
write(name_pre % [size, size])
end
FileList["*favicon.ico"].each do |img|
File.delete img
end
puts "Creating favicon.ico..."
Magick::Image::read(origin).first.resize(32, 32).write("favicon.ico")
puts "Cleaning up..."
File.delete origin
end