• Stars
    star
    19
  • Rank 1,163,249 (Top 23 %)
  • Language
    Crystal
  • License
    MIT License
  • Created about 8 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Write GIF images in pure Crystal

stumpy_gif

Interface

  • StumpyGIF.write(frames : Array(Canvas), path_or_io, delay_between_frames = 10) saves a list of frames (canvasses) as a GIF image file, delay_between_frames is in 1/100 of a second
  • Canvas and RGBA from stumpy_core

Usage

Writing

require "stumpy_gif"
include StumpyGIF

frames = [] of Canvas

(0..5).each do |z|
  canvas = Canvas.new(256, 256)

  (0..255).each do |x|
    (0..255).each do |y|
      color = RGBA.from_rgb_n([x, y, z * 51], 8)
      canvas[x, y] = color
    end
  end

  frames << canvas
end

StumpyGIF.write(frames, "rainbow.gif")

Left to right: Websafe, median split, NeuQuant

GIF image with an animated color gradient GIF image with an animated color gradient GIF image with an animated color gradient

(See examples/ for more examples)

Color Quantization Methods

  • Use Websafe colors
  • Median Split
  • NeuQuant

References

Contributors

Thanks goes to these wonderful people (emoji key):


Leon


Sam


Stepan Melnikov

πŸ’»

Dmitry Bochkarev

πŸ’»

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