-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmake_wallet_mask.rb
executable file
·55 lines (42 loc) · 1.59 KB
/
make_wallet_mask.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
43
44
45
46
47
48
49
50
51
52
53
54
55
#! /usr/bin/env ruby
require "qrencoder"
require "RMagick"
include Magick
PIXELS_PER_MODULE = 13
wallet = `vanitygen 1`
private_key = wallet.match(/Privkey: (.*)$/)[1]
address = wallet.match(/Address: (.*)$/)[1]
private_key_qr = QREncoder.encode(private_key, :correction => :high)
private_key_qr.png(:margin => 2, :pixels_per_module => PIXELS_PER_MODULE).save('private_key.png')
private_key_qr = Image::read('private_key.png').first
`rm -P private_key.png`
address_qr = QREncoder.encode(address, :correction => :high)
address_qr.png(:margin => 2, :pixels_per_module => PIXELS_PER_MODULE).save('address.png')
address_qr = Image::read('address.png').first.resize(525,525)
`rm -P address.png`
template = Image::read('mask_template.png').first
template.composite!(address_qr, 25, 350, OverCompositeOp)
template.composite!(private_key_qr, 900, 150, OverCompositeOp)
font_name = File.expand_path(File.join(File.dirname(__FILE__), "OCRA.ttf"))
private_key_image = Image.read("caption:#{private_key}") {
self.font = font_name
self.fill = 'black'
self.stroke = 'transparent'
self.pointsize = 67
self.gravity = NorthGravity
self.size = 860
}.first
private_key_image.rotate!(-90)
template.composite!(private_key_image, 615, 20, OverCompositeOp)
address_image = Image.read("caption:#{address}") {
self.font = font_name
self.fill = 'black'
self.stroke = 'transparent'
self.pointsize = 58
self.gravity = NorthWestGravity
self.size = 512
}.first
template.composite!(address_image, 50, 110, OverCompositeOp)
template = template.flop().negate()
template.write('mask.png')
`open mask.png`