All Projects → wvanbergen → Chunky_png

wvanbergen / Chunky_png

Licence: mit
Read/write access to PNG images in pure Ruby.

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to Chunky png

Libvips
A fast image processing library with low memory needs.
Stars: ✭ 6,094 (+528.25%)
Mutual labels:  png
Pixterm
Draw images in your ANSI terminal with true color
Stars: ✭ 782 (-19.38%)
Mutual labels:  png
Repng
React component to PNG converter
Stars: ✭ 856 (-11.75%)
Mutual labels:  png
Bbmetalimage
A high performance Swift library for GPU-accelerated image/video processing based on Metal.
Stars: ✭ 677 (-30.21%)
Mutual labels:  png
Svgexport
SVG to PNG/JPEG command-line tool and Node.js module
Stars: ✭ 731 (-24.64%)
Mutual labels:  png
Scrimage
Java, Scala and Kotlin image processing library
Stars: ✭ 792 (-18.35%)
Mutual labels:  png
Sdwebimage
Asynchronous image downloader with cache support as a UIImageView category
Stars: ✭ 23,928 (+2366.8%)
Mutual labels:  png
Isparta
APNG、WebP converter
Stars: ✭ 942 (-2.89%)
Mutual labels:  png
Flyimg
Dockerized PHP7 application runs as a Microservice to resize and crop images on the fly. Get optimised images with MozJPEG, WebP or PNG using ImageMagick. Includes face detection, cropping, face blurring, image rotation and many other options. Abstract storage based on FlySystem in order to store images on any provider (local, AWS S3...).
Stars: ✭ 762 (-21.44%)
Mutual labels:  png
Imageio
画像の入出力
Stars: ✭ 9 (-99.07%)
Mutual labels:  png
Php Qrcode
A QR Code generator for PHP7.4+
Stars: ✭ 685 (-29.38%)
Mutual labels:  png
Img Optimizer Gradle Plugin
一款用于优化png图片的gradle插件,有效减少APK体积,支持极限压缩和无损压缩。
Stars: ✭ 718 (-25.98%)
Mutual labels:  png
Is Animated
Checks if image is animated 🎞
Stars: ✭ 17 (-98.25%)
Mutual labels:  png
Quickshot
Capture images of any View, SurfaceView or Bitmap from your Android app in: .jpg .png or .nomedia with simple oneliner codes.
Stars: ✭ 663 (-31.65%)
Mutual labels:  png
Mapbox Gl Print Export For Port
Print/Export for Mapbox GL
Stars: ✭ 14 (-98.56%)
Mutual labels:  png
Optimizt
CLI image optimization tool
Stars: ✭ 594 (-38.76%)
Mutual labels:  png
Image Optimizer
Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.
Stars: ✭ 785 (-19.07%)
Mutual labels:  png
Ruby Gem Downloads Badge
Clean and simple gem downloads count badge, courtesy of http://shields.io/. You can checkout the application directly at the following URL:
Stars: ✭ 29 (-97.01%)
Mutual labels:  png
Bsnes Mt
bsnes-based SNES emulator featuring pixel-perfect integer scaling, PNG screenshots, built-in hotkeys, translations, bug fixes, and more.
Stars: ✭ 22 (-97.73%)
Mutual labels:  png
Stegify
🔍 Go tool for LSB steganography, capable of hiding any file within an image.
Stars: ✭ 927 (-4.43%)
Mutual labels:  png

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. :-)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].