All Projects → stumpycr → stumpy_png

stumpycr / stumpy_png

Licence: MIT license
Read/Write PNG images in pure Crystal

Programming Languages

crystal
512 projects

Projects that are alternatives of or similar to stumpy png

pngloss
Lossy compression of PNG images
Stars: ✭ 73 (-26.26%)
Mutual labels:  png
public
Some public files that I can link to: icons, screenshots, etc.
Stars: ✭ 29 (-70.71%)
Mutual labels:  png
png pong
A pure Rust PNG image decoder and encoder based on lodepng.
Stars: ✭ 21 (-78.79%)
Mutual labels:  png
vectorexpress-api
Vector Express is a free service and API for converting, analyzing and processing vector files.
Stars: ✭ 66 (-33.33%)
Mutual labels:  png
xaringanBuilder
An R package for building xaringan slides into multiple outputs, including html, pdf, png, gif, pptx, and mp4.
Stars: ✭ 157 (+58.59%)
Mutual labels:  png
r6operators
r6operators is a collection of high-quality vectorized Rainbow Six: Siege Operator icons & metadata for Node.js
Stars: ✭ 75 (-24.24%)
Mutual labels:  png
png2svg
🔀 Convert small PNG images to SVG Tiny 1.2
Stars: ✭ 219 (+121.21%)
Mutual labels:  png
nimPNG
PNG (Portable Network Graphics) decoder and encoder written in Nim
Stars: ✭ 81 (-18.18%)
Mutual labels:  png
imagecodecs
Image transformation, compression, and decompression codecs. Forked from https://pypi.org/project/imagecodecs
Stars: ✭ 56 (-43.43%)
Mutual labels:  png
StbSharp
C# port of the famous C framework
Stars: ✭ 62 (-37.37%)
Mutual labels:  png
stegjs
Encrypt message to PNG image.
Stars: ✭ 18 (-81.82%)
Mutual labels:  png
oculante
A minimalistic crossplatform image viewer written in rust
Stars: ✭ 169 (+70.71%)
Mutual labels:  png
gfxprim
Open-source modular 2D bitmap graphics library with emphasis on speed and correctness.
Stars: ✭ 32 (-67.68%)
Mutual labels:  png
arrow-finder
These docs help you to find and use arrows you need more quickly
Stars: ✭ 24 (-75.76%)
Mutual labels:  png
ICNS2ICO
ICNS2ICO lets you easily convert icons from the Apple's ICNS format to the Windows ICO format.
Stars: ✭ 17 (-82.83%)
Mutual labels:  png
node-pdftocairo
📃 Node.js wrapper for pdftocairo - PDF to PNG/JPEG/TIFF/PDF/PS/EPS/SVG using cairo
Stars: ✭ 17 (-82.83%)
Mutual labels:  png
3dn-bip
A Python library for Blender addons. Blazingly fast preview loads in Blender. Images of arbitrary size. bpy.utils.previews drop-in replacement.
Stars: ✭ 41 (-58.59%)
Mutual labels:  png
sail
The missing small and fast image decoding library for humans (not for machines) ⛵ https://sail.software
Stars: ✭ 206 (+108.08%)
Mutual labels:  png
documentspark
💖 DocumentSpark - Simple secure document viewing server. Converts a document to a picture of its pages. Content disarm and reconstruction. CDR. Formerly p2. The CDR solution for ViewFinder remote browser.
Stars: ✭ 211 (+113.13%)
Mutual labels:  png
dom-to-image-more
Generates an image from a DOM node using HTML5 canvas
Stars: ✭ 231 (+133.33%)
Mutual labels:  png

stumpy_png

CI

Documentation

Interface

  • StumpyPNG.read(path : String) : Canvas read a PNG image file from a path
  • StumpyPNG.read(io : IO) : Canvas read a PNG image file from any IO object
  • StumpyPNG.write(canvas, path : String, bit_depth: 16, color_type: :rgb_alpha) save a canvas as a PNG image file
  • StumpyPNG.write(canvas, io : IO, bit_depth: 16, color_type: :rgb_alpha) write a canvas as PNG data to any IO object
    • bit_depth is optional, valid values are 8 and 16(default)
    • color_type is optional, valid values are :grayscale, :grayscale_alpha, :rgb and :rgb_alpha(default)
  • StumpyPNG::PNG, helper class to store some state while parsing PNG files
  • Canvas and RGBA from stumpy_core

Usage

Install the stumpy_png shard

  1. shards init
  2. Add the dependency to the shard.yml file
...
dependencies:
  stumpy_png:
    github: stumpycr/stumpy_png
    version: "~> 5.0"
...
  1. shards install

Reading

require "stumpy_png"

canvas = StumpyPNG.read("foo.png")
r, g, b = canvas[0, 0].to_rgb8
puts "red=#{r}, green=#{g}, blue=#{b}"

Writing

require "stumpy_png"
include StumpyPNG

canvas = Canvas.new(256, 256)

(0..255).each do |x|
  (0..255).each do |y|
    # RGBA.from_rgb_n(values, bit_depth) is an internal helper method
    # that creates an RGBA object from a rgb triplet with a given bit depth
    color = RGBA.from_rgb_n(x, y, 255, 8)
    canvas[x, y] = color
  end
end

StumpyPNG.write(canvas, "rainbow.png")

PNG image with a color gradient

(See examples/ for more examples)

Reading PNG files

Color Types

  • Grayscale
  • Grayscale + Alpha
  • RGB
  • RGB + Alpha
  • Palette

Filter Types

  • None
  • Sub
  • Up
  • Average
  • Paeth

Interlacing Methods

  • None
  • Adam7

Ancillary Chunks

None are supported right now.

Writing

  • RGB with 8 or 16 bits
  • RGB + Alpha with 8 or 16 bits
  • Grayscale with 8 or 16 bits
  • Grayscale + Alpha with 8 or 16 bits

Troubleshooting

If you run into errors like

/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status

make sure zlib is installed (Installing zlib under ubuntu).

Contributors

Thanks goes to these wonderful people (emoji key):


Chris Hobbs

💻

Ary Borenszweig

💻

Alex Muscar

💻

Dru Jensen

💻

kojix2

📖

obskyr

💻

r00ster

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

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].