🕷 software projects

by ryan davis



sitemap

png

PNG via ruby

PNG is an almost-pure-ruby PNG library. It lets you write a PNG without any C libraries.

  • Very simple interface.
  • Outputs simple PNG files with ease.
  • Basic PNG reader as well (someday it might do compositing and the like!).
  • Almost pure ruby, does require a compiler.
1
2
3
4
5
6
7
8
9
10
11
12
require 'png'

canvas = PNG::Canvas.new 200, 200

# Set a point to a color
canvas[100, 100] = PNG::Color::Black

# draw an anti-aliased line
canvas.line 50, 50, 100, 50, PNG::Color::Blue

png = PNG.new canvas
png.save 'blah.png'

Get The Code

If you just want to use png, you can install it via RubyGems:
gem install png
Fork me on GitHub If you want to hack on png, clone it from GitHub:
git clone git://github.com/seattlerb/png

Latest Activity