zpng 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ require 'zpng'
3
+ include ZPNG
4
+
5
+ img = Image.new(File.join(File.dirname(__FILE__),"http.png"))
6
+
7
+ puts "[.] original:"
8
+ puts img.to_s
9
+ puts
10
+
11
+ img.width.times do |x|
12
+ img[x,0] = (x % 2 == 0) ? Color::WHITE : Color::BLACK
13
+ end
14
+
15
+ puts "[.] modified:"
16
+ puts img.to_s
17
+
18
+ File.open("http-modified.png","wb") do |f|
19
+ f << img.export
20
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,52 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ ASCII_QR = <<EOF
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
+ EOF
40
+
41
+ describe "ZPNG png2ascii" do
42
+ it "should have QR examples" do
43
+ Dir[File.join(SAMPLES_DIR,'qr_*.png')].should_not be_empty
44
+ end
45
+ Dir[File.join(SAMPLES_DIR,'qr_*.png')].each do |fname|
46
+ describe fname do
47
+ it "generates a nice ascii img" do
48
+ ZPNG::Image.new(fname).to_s(:white => '.', :black => '#').strip.should == ASCII_QR.strip
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,63 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ ASCII_MODIFIED_QR = <<EOF
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
+ EOF
40
+
41
+ samples =
42
+ if ENV['SAMPLES']
43
+ ENV['SAMPLES'].split(' ')
44
+ else
45
+ Dir[File.join(SAMPLES_DIR,'qr_*.png')]
46
+ end
47
+
48
+ describe "ZPNG modify" do
49
+ it "should have QR examples" do
50
+ samples.should_not be_empty
51
+ end
52
+ samples.each do |fname|
53
+ describe fname.sub(File.dirname(SAMPLES_DIR)+'/','') do
54
+ img = ZPNG::Image.new(fname)
55
+ it "modifies img - color=#{img.hdr.color}, depth=#{img.hdr.depth}, bpp=#{img.hdr.bpp}" do
56
+ img.width.times do |x|
57
+ img[x,0] = (x%2==0) ? ZPNG::Color::WHITE : ZPNG::Color::BLACK
58
+ end
59
+ img.to_s(:white => '.', :black => '#').strip.should == ASCII_MODIFIED_QR.strip
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,18 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'zpng'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
13
+
14
+ SAMPLES_DIR = File.join(
15
+ File.dirname(
16
+ File.dirname(
17
+ File.expand_path(__FILE__))),
18
+ "samples")
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Zpng" do
4
+ it "fails" do
5
+ # fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zpng
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andrey "Zed" Zaikin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: colorize
16
+ requirement: &70359178912700 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70359178912700
25
+ - !ruby/object:Gem::Dependency
26
+ name: hexdump
27
+ requirement: &70359178930900 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70359178930900
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70359178930200 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 2.8.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70359178930200
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: &70359178929280 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70359178929280
58
+ - !ruby/object:Gem::Dependency
59
+ name: jeweler
60
+ requirement: &70359178928180 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 1.6.4
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70359178928180
69
+ - !ruby/object:Gem::Dependency
70
+ name: rcov
71
+ requirement: &70359178927440 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70359178927440
80
+ description:
81
+ email: zed.0xff@gmail.com
82
+ executables:
83
+ - zpng
84
+ extensions: []
85
+ extra_rdoc_files:
86
+ - LICENSE.txt
87
+ - README.md
88
+ - README.md.tpl
89
+ files:
90
+ - .document
91
+ - .rspec
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README.md
96
+ - README.md.tpl
97
+ - Rakefile
98
+ - VERSION
99
+ - bin/zpng
100
+ - lib/zpng.rb
101
+ - lib/zpng/block.rb
102
+ - lib/zpng/chunk.rb
103
+ - lib/zpng/cli.rb
104
+ - lib/zpng/color.rb
105
+ - lib/zpng/image.rb
106
+ - lib/zpng/scan_line.rb
107
+ - samples/modify.rb
108
+ - samples/qr_aux_chunks.png
109
+ - samples/qr_bw.png
110
+ - samples/qr_gray_alpha.png
111
+ - samples/qr_grayscale.png
112
+ - samples/qr_plte.png
113
+ - samples/qr_plte_bw.png
114
+ - samples/qr_rgb.png
115
+ - samples/qr_rgba.png
116
+ - spec/ascii_spec.rb
117
+ - spec/modify_spec.rb
118
+ - spec/spec_helper.rb
119
+ - spec/zpng_spec.rb
120
+ homepage: http://github.com/zed-0xff/zpng
121
+ licenses:
122
+ - MIT
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ segments:
134
+ - 0
135
+ hash: 958619003383702064
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 1.8.10
145
+ signing_key:
146
+ specification_version: 3
147
+ summary: pure ruby PNG file manipulation & validation
148
+ test_files: []