File: test_attach.rb

package info (click to toggle)
libimlib2-ruby 0.5.2-2.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 2,552 kB
  • sloc: ansic: 4,671; ruby: 250; makefile: 7
file content (23 lines) | stat: -rwxr-xr-x 510 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env ruby

OUT_PATH = 'attach.jpg'

require 'imlib2'

# load image
im_path = ARGV.shift || (File::dirname($0) << '/images/bill_gates.jpg')
puts "Loading input image \"#{im_path}\"..."
im = Imlib2::Image.load(im_path)

# assign key, generate random number
key, val = (ARGV.shift || 'asdf'), (ARGV.shift || rand(10000)).to_i

puts "random number: #{val}"
puts "key: #{key}"
im[key] = val

puts "testing get_attach_value: #{im[key]}"

# save output image
puts 'Saving output image...'
im.save(OUT_PATH)