A fast and convenient image processing library
- Image formats
- JPEG (through libjpeg-turbo)
- PNG (through libspng)
- PPM
- StumpyCore
- WebP (through libwebp)
- WebP 1.3+ linking flags are used by default. If you have an older version installed, compile with the
-Dlegacy_webp
flag to skip the requirement forlibsharpyuv
.
- WebP 1.3+ linking flags are used by default. If you have an older version installed, compile with the
- Image operations
- Bilinear resize
- Box blur
- Brightness
- Channel swap
- Contrast
- Crop
- Gaussian blur
- Horizontal blur
- Padding
- Rotation
- Vertical blur
-
Add the dependency to your
shard.yml
:dependencies: pluto: github: phenopolis/pluto
-
Run
shards install
.
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/desert.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)
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/desert.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.
See the API or the spec/
folder for more examples.
See BENCHMARKS.md
.
- Fork it (https://github.com/phenopolis/pluto/fork).
- Create your feature branch (
git checkout -b my-new-feature
). - Commit your changes (
git commit -am 'Add some feature'
). - Push to the branch (
git push origin my-new-feature
). - Create a new Pull Request.