pluto

A fast and convenient image processing library image-processing jpeg ppm png webp lossless lossy
1.0.1 Latest release released
phenopolis/pluto
68 5 9
Phenopolis

logo

A fast and convenient image processing library

Currently supported

  • Image formats
  • Image operations
    • Bilinear resize
    • Box blur
    • Brightness
    • Channel swap
    • Contrast
    • Crop
    • Gaussian blur
    • Horizontal blur
    • Vertical blur

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      pluto:
        github: phenopolis/pluto
    
  2. Run shards install.

Usage

Basic

require "pluto"

# Formats requiring linkinkg a C library must be explicitly `require`d
require "pluto/format/jpeg"
require "pluto/format/png"
require "pluto/format/webp"

image = File.open("lib/pluto_samples/pluto.png") do |file|
  Pluto::ImageRGBA.from_png(file)
end

image.contrast(-100)  # Creates a new object
image.contrast!(-100) # Modifies the existing object

io = IO::Memory.new
image.to_jpeg(io)
io.rewind
File.write("output.jpeg", io)

StumpyCore

Pluto can convert to and from StumpyCore Canvas objects, so any format that Stumpy supports can be usable with Pluto as well.

require "pluto"
require "stumpy_png"

canvas = StumpyPNG.read("lib/pluto_samples/pluto.png") # => StumpyCore::Canvas
image = Pluto::ImageRGBA.from_stumpy(canvas)           # => Pluto::ImageRGBA
image.to_stumpy                                        # => StumpyCore::Canvas

Note

Converting from a StumpyCore::Canvas created from a 16-bit image will result in a loss of information, since Pluto currently only supports 8 bit.

More

See the API or the spec/ folder for more examples.

Benchmarks

See BENCHMARKS.md.

Contributing

  1. Fork it (https://github.com/phenopolis/pluto/fork).
  2. Create your feature branch (git checkout -b my-new-feature).
  3. Commit your changes (git commit -am 'Add some feature').
  4. Push to the branch (git push origin my-new-feature).
  5. Create a new Pull Request.
pluto:
  github: phenopolis/pluto
  version: ~> 1.0.1
License ISC
Crystal 1.7.2

Dependencies 1

Development Dependencies 3

  • ameba ~> 1.4.3
    {'github' => 'crystal-ameba/ameba', 'version' => '~> 1.4.3'}
  • pluto_samples
    {'github' => 'phenopolis/pluto-samples'}
  • stumpy_png
    {'github' => 'stumpycr/stumpy_png'}

Dependents 0

Last synced .
search fire star recently