-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.md.tpl
90 lines (57 loc) · 1.75 KB
/
README.md.tpl
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
zpng [![Build Status](https://secure.travis-ci.org/zed-0xff/zpng.png)](http://secure.travis-ci.org/zed-0xff/zpng) [![Dependency Status](https://gemnasium.com/zed-0xff/zpng.png)](https://gemnasium.com/zed-0xff/zpng)
======
Description
-----------
A pure ruby PNG file manipulation & validation
(If you need a high-level PNG creation toolkit - take a look at [SugarPNG](https://github.com/zed-0xff/sugar_png))
Installation
------------
gem install zpng
Comparison
----------
* supports `iTXt` (international text) chunks
* full support of 16-bit color & alpha depth
Usage
-----
% zpng -h
### Info
% zpng qr_rgb.png
### Info (verbose)
% zpng -v qr_rgb.png
( add more `-v`'s for even more verbose output)
### Chunks
% zpng --chunks qr_aux_chunks.png
### ASCII
source image: ![qr_rgb.png](https://github.com/zed-0xff/zpng/raw/master/samples/qr_rgb.png)
% zpng --ascii --wide qr_rgb.png
### Scanlines
% zpng --scanlines qr_rgb.png
### Palette
% zpng --palette qr_plte_bw.png
## Image manipulation
#!/usr/bin/env ruby
require 'zpng'
include ZPNG
img = Image.new(File.join(File.dirname(__FILE__),"http.png"))
puts "[.] original:"
puts img.to_s
puts
img.width.times do |x|
img[x,0] = (x % 2 == 0) ? Color::WHITE : Color::BLACK
end
puts "[.] modified:"
puts img.to_s
File.open("http-modified.png","wb") do |f|
f << img.export
end
## Create 16x16 transparent PNG
#!/usr/bin/env ruby
require 'zpng'
include ZPNG
img = Image.new :width => 16, :height => 16
File.open("16x16.png","wb") do |f|
f << img.export
end
License
-------
Released under the MIT License. See the [LICENSE](https://github.com/zed-0xff/zpng/blob/master/LICENSE.txt) file for further details.