https://github.com/wvanbergen/chunky_png
Read/write access to PNG images in pure Ruby.
https://github.com/wvanbergen/chunky_png
Keywords
chunkypng png png-decoder png-encoder rdoc
Keywords from Contributors
activejob activerecord mvc rubygem rack rubocop rspec feature-flag xslt xerces
Last synced: about 18 hours ago
JSON representation
Repository metadata
Read/write access to PNG images in pure Ruby.
- Host: GitHub
- URL: https://github.com/wvanbergen/chunky_png
- Owner: wvanbergen
- License: mit
- Created: 2010-01-04T06:56:19.000Z (about 16 years ago)
- Default Branch: master
- Last Pushed: 2024-06-03T10:22:43.000Z (over 1 year ago)
- Last Synced: 2026-02-28T08:42:38.639Z (3 days ago)
- Topics: chunkypng, png, png-decoder, png-encoder, rdoc
- Language: Ruby
- Homepage: https://chunkypng.com
- Size: 1.19 MB
- Stars: 1,064
- Watchers: 24
- Forks: 103
- Open Issues: 16
- Releases: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.rdoc
- Contributing: CONTRIBUTING.rdoc
- License: LICENSE
README.md
ChunkyPNG
This library can read and write PNG files. It is written in pure Ruby for
maximum portability. Let me rephrase: it does NOT require RMagick or any other
memory leaking image library.
Features
- Decodes any image that the PNG standard allows. This includes all standard
color modes, all bit depths, all transparency, and interlacing and filtering
options. - Encodes images supports all color modes (true color, grayscale, and indexed)
and transparency for all these color modes. The best color mode will be
chosen automatically, based on the amount of used colors. - R/W access to the image's pixels.
- R/W access to all image metadata that is stored in chunks.
- Memory efficient (uses a Fixnum, i.e. 4 or 8 bytes of memory per pixel,
depending on the hardware) - Reasonably fast for Ruby standards, by only using integer math and a highly
optimized saving routine. - Works on every currently supported Ruby version (2.5+)
- Interoperability with RMagick if you really have to.
Also, have a look at OilyPNG which
is a mixin module that implements some of the ChunkyPNG algorithms in C, which
provides a massive speed boost to encoding and decoding.
Usage
require 'chunky_png'
# Creating an image from scratch, save as an interlaced PNG
png = ChunkyPNG::Image.new(16, 16, ChunkyPNG::Color::TRANSPARENT)
png[1,1] = ChunkyPNG::Color.rgba(10, 20, 30, 128)
png[2,1] = ChunkyPNG::Color('black @ 0.5')
png.save('filename.png', :interlace => true)
# Compose images using alpha blending.
avatar = ChunkyPNG::Image.from_file('avatar.png')
badge = ChunkyPNG::Image.from_file('no_ie_badge.png')
avatar.compose!(badge, 10, 10)
avatar.save('composited.png', :fast_rgba) # Force the fast saving routine.
# Accessing metadata
image = ChunkyPNG::Image.from_file('with_metadata.png')
puts image.metadata['Title']
image.metadata['Author'] = 'Willem van Bergen'
image.save('with_metadata.png') # Overwrite file
# Low level access to PNG chunks
png_stream = ChunkyPNG::Datastream.from_file('filename.png')
png_stream.each_chunk { |chunk| p chunk.type }
Also check out the screencast on the ChunkyPNG homepage by John Davison,
which illustrates basic usage of the library on the ChunkyPNG
website.
For more information, see the project
wiki or the RDOC
documentation.
Security warning
ChunkyPNG is vulnerable to decompression bombs, which means that ChunkyPNG is
vulnerable to DOS attacks by running out of memory when loading a specifically
crafted PNG file. Because of the pure-Ruby nature of the library it is very hard
to fix this problem in the library itself.
In order to safely deal with untrusted images, you should make sure to do the
image processing using ChunkyPNG in a separate process, e.g. by using fork or a
background processing library.
About
The library is written by Willem van Bergen for Floorplanner.com, and released
under the MIT license (see LICENSE). Please contact me for questions or
remarks.
I generally consider this library to be feature complete. I will gladly accept
patches to fix bugs and improve performance, but I will generally be hesitant
to accept new features or API endpoints. Before contributing, please read
CONTRIBUTING.rdoc that explains this in more detail.
Please check out CHANGELOG.rdoc to see what changed in all versions.
P.S.: The name of this library is intentionally similar to Chunky Bacon and
Chunky GIF. Use Google if you want to know why. :-)
Owner metadata
- Name: Willem van Bergen
- Login: wvanbergen
- Email:
- Kind: user
- Description:
- Website: http://www.vanbergen.org/
- Location: Ottawa, Canada
- Twitter: wvanbergen
- Company:
- Icon url: https://avatars.githubusercontent.com/u/15870?u=5118b88e96fbfc673dbc712cefcf06797964f2f9&v=4
- Repositories: 48
- Last ynced at: 2023-04-11T16:46:25.452Z
- Profile URL: https://github.com/wvanbergen
GitHub Events
Total
- Fork event: 3
- Watch event: 17
- Issue comment event: 1
Last Year
- Fork event: 1
- Watch event: 11
Committers metadata
Last synced: 1 day ago
Total Commits: 538
Total Committers: 35
Avg Commits per committer: 15.371
Development Distribution Score (DDS): 0.191
Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| Willem van Bergen | w****m@v****g | 435 |
| Joe Lencioni | j****i@b****m | 21 |
| Jen Hamon | j****n@g****m | 15 |
| 3ifbyw | 3****w@g****m | 15 |
| Aleksey | i****g@g****m | 10 |
| Bob Lail | b****y@g****m | 3 |
| Troy Ross | t****s@m****m | 2 |
| Ben Johnson | b****n@y****m | 2 |
| Chris Seaton | c****s@c****m | 2 |
| Dominick | d****o@g****m | 2 |
| Jeremy Evans | c****e@j****t | 2 |
| Marc-Andre Lafortune | g****b@m****a | 2 |
| Matthew Kobs | m****s@c****g | 2 |
| Olle Jonsson | o****n@g****m | 2 |
| Richard Blair | r****d@b****m | 2 |
| Stephen Eckenrode | s****e@p****m | 2 |
| dfens | m****p@g****m | 1 |
| Didip Kerabat | d****p@d****l | 1 |
| Ryan J Daw | r****n@m****e | 1 |
| Zete Lui | m****s@k****d | 1 |
| Thiébaud Weksteen | t****d@w****r | 1 |
| Theodor Tonum | t****r@t****o | 1 |
| Pedro Furtado | p****o@g****m | 1 |
| Olivier Lacan | hi@o****m | 1 |
| Michal Pokorný | p****k@r****z | 1 |
| Marti Kaljuve | m****k@g****m | 1 |
| Mark Dodwell | m****c | 1 |
| Manuel Franco | m****a@g****m | 1 |
| Kornelius Kalnbach | m****y@r****e | 1 |
| Joel Stemmer | s****h@g****m | 1 |
| and 5 more... | ||
Committer domains:
- rubychan.de: 1
- rny.cz: 1
- olivierlacan.com: 1
- tonum.no: 1
- weksteen.fr: 1
- k.ed: 1
- mobify.me: 1
- panoramaed.com: 1
- blairingthoughts.com: 1
- cph.org: 1
- marc-andre.ca: 1
- jeremyevans.net: 1
- chrisseaton.com: 1
- mandiant.com: 1
- brigade.com: 1
- vanbergen.org: 1
Issue and Pull Request metadata
Last synced: 14 days ago
Total issues: 47
Total pull requests: 56
Average time to close issues: 4 months
Average time to close pull requests: 3 months
Total issue authors: 46
Total pull request authors: 28
Average comments per issue: 2.79
Average comments per pull request: 1.27
Merged pull request: 38
Bot issues: 0
Bot pull requests: 0
Past year issues: 1
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 1
Past year pull request authors: 0
Past year average comments per issue: 0.0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- ghost (2)
- smranta (1)
- kamil-gwozdz (1)
- moonhouse (1)
- istrasci (1)
- clord (1)
- polarlights (1)
- wvanbergen (1)
- diggde (1)
- ebds (1)
- rubyFeedback (1)
- cpanato (1)
- catmando (1)
- chriseppstein (1)
- mm580486 (1)
Top Pull Request Authors
- wvanbergen (20)
- lencioni (5)
- jeremyevans (3)
- olleolleolle (2)
- murbanski (2)
- ReviakinAleksey (2)
- ydah (2)
- kobsy (2)
- boblail (1)
- mkdynamic (1)
- pedrofurtado (1)
- jeroentheuns (1)
- TheHashTableSlasher (1)
- Atul9 (1)
- casperisfine (1)
Top Issue Labels
Top Pull Request Labels
Package metadata
- Total packages: 5
-
Total downloads:
- rubygems: 379,101,566 total
- Total docker downloads: 1,339,200,084
- Total dependent packages: 216 (may contain duplicates)
- Total dependent repositories: 46,228 (may contain duplicates)
- Total versions: 154
- Total maintainers: 1
gem.coop: chunky_png
This pure Ruby library can read and write PNG images without depending on an external image library, like RMagick. It tries to be memory efficient and reasonably fast. It supports reading and writing all PNG variants that are defined in the specification, with one limitation: only 8-bit color depth is supported. It supports all transparency, interlacing and filtering options the PNG specifications allows. It can also read and write textual metadata from PNG files. Low-level read/write access to PNG chunks is also possible. This library supports simple drawing on the image canvas and simple operations like alpha composition and cropping. Finally, it can import from and export to RMagick for interoperability. Also, have a look at OilyPNG at https://github.com/wvanbergen/oily_png. OilyPNG is a drop in mixin module that implements some of the ChunkyPNG algorithms in C, which provides a massive speed boost to encoding and decoding.
- Homepage: https://github.com/wvanbergen/chunky_png/wiki
- Documentation: http://www.rubydoc.info/gems/chunky_png/
- Licenses: MIT
- Latest release: 1.4.0 (published about 5 years ago)
- Last Synced: 2026-03-02T09:02:52.523Z (1 day ago)
- Versions: 67
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 189,567,201 Total
- Docker Downloads: 669,600,042
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.044%
- Downloads: 0.131%
- Maintainers (1)
debian-13: ruby-chunky-png
- Homepage: https://github.com/wvanbergen/chunky_png/wiki
- Documentation: https://packages.debian.org/trixie/ruby-chunky-png
- Licenses: mit
- Latest release: 1.4.0-1 (published 19 days ago)
- Last Synced: 2026-02-13T13:13:56.632Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.266%
- Stargazers count: 0.449%
- Forks count: 0.614%
rubygems.org: chunky_png
This pure Ruby library can read and write PNG images without depending on an external image library, like RMagick. It tries to be memory efficient and reasonably fast. It supports reading and writing all PNG variants that are defined in the specification, with one limitation: only 8-bit color depth is supported. It supports all transparency, interlacing and filtering options the PNG specifications allows. It can also read and write textual metadata from PNG files. Low-level read/write access to PNG chunks is also possible. This library supports simple drawing on the image canvas and simple operations like alpha composition and cropping. Finally, it can import from and export to RMagick for interoperability. Also, have a look at OilyPNG at https://github.com/wvanbergen/oily_png. OilyPNG is a drop in mixin module that implements some of the ChunkyPNG algorithms in C, which provides a massive speed boost to encoding and decoding.
- Homepage: https://github.com/wvanbergen/chunky_png/wiki
- Documentation: http://www.rubydoc.info/gems/chunky_png/
- Licenses: MIT
- Latest release: 1.4.0 (published about 5 years ago)
- Last Synced: 2026-03-01T23:01:29.358Z (1 day ago)
- Versions: 67
- Dependent Packages: 216
- Dependent Repositories: 46,228
- Downloads: 189,534,365 Total
- Docker Downloads: 669,600,042
-
Rankings:
- Downloads: 0.13%
- Dependent repos count: 0.157%
- Docker downloads count: 0.169%
- Dependent packages count: 0.179%
- Average: 0.855%
- Stargazers count: 1.881%
- Forks count: 2.612%
- Maintainers (1)
proxy.golang.org: github.com/wvanbergen/chunky_png
- Homepage:
- Documentation: https://pkg.go.dev/github.com/wvanbergen/chunky_png#section-documentation
- Licenses: mit
- Latest release: v1.4.0 (published about 5 years ago)
- Last Synced: 2026-02-28T20:00:41.638Z (3 days ago)
- Versions: 18
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Stargazers count: 2.026%
- Forks count: 2.608%
- Average: 6.243%
- Dependent packages count: 9.56%
- Dependent repos count: 10.779%
guix: ruby-chunky-png
Ruby library to handle PNG images
- Homepage: https://github.com/wvanbergen/chunky_png/wiki
- Documentation: https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/ruby-xyz.scm#n2001
- Licenses: expat
- Latest release: 1.4.0 (published about 20 hours ago)
- Last Synced: 2026-03-02T18:57:36.528Z (about 20 hours ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
Dependencies
- actions/checkout v2 composite
- ruby/setup-ruby v1 composite
- jekyll ~> 3.3 development
- jekyll-commonmark >= 0 development
- jekyll-theme-cayman >= 0 development
- kramdown-parser-gfm >= 0 development
- jruby-openssl >= 0
- rake >= 0 development
- rspec ~> 3 development
- standard >= 0 development
- yard ~> 0.9 development
Score: 31.80469446787309