0.0
No commit activity in last 3 years
No release in over 3 years
Create pixel sorted gifs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
~> 10.0
~> 3.0
~> 0.12.0

Runtime

~> 0.24.0
~> 0.3.0.20161108
>= 1.8.2, ~> 1.8
>= 2.16.0, ~> 2.16
 Project Readme

PixelDreamer

Installation

Install RMagick and ImageMagick from here: RMagick

Add this line to your application's Gemfile:

gem 'pixel_dreamer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pixel_dreamer

Usage

ImageDreamer

To use pixel dreamer you must first create a new PixelDreamer::ImageDreamer instance to do this you must pass in the uri of the image you will be pixel sorting:

image = PixelDreamer::ImageDreamer.new('/uri/image.png')

you can also pass in an image to be laid on top of the image that is pixel sorted, overlay image is optional:

image = PixelDreamer::ImageDreamer.new('/uri/image.png', 'overlay/image.png')

brute_sort_save_with_settings

pixel sorts an image and outputs a text file with settings used. once the image has been instantiated you can run this method without passing in any parameters. by default it runs with these paramaters: { settings: DEFAULTS, output_name: nil, gif: false, output_folder: false }

image.brute_sort_save_with_settings

or with these parameters

image.brute_sort_save_with_settings(settings: PixelDreamer::Constants::DEFAULTS, output_name: nil, 
                                    gif: false, output_folder: false)

or

image.brute_sort_save_with_settings(settings: { reverse: false, vertical: false, diagonal: false,
                                                 smooth: false, method: 'sum-rgb', verbose: false,
                                                 min: Float::INFINITY, max: Float::INFINITY,
                                                 trusted: false, middle: false })

also read the documentation for pxlsrt to get an idea of what these parameters do

glitch_sequence

creates a sequence of pixel sorted images based on the setting hash and a sequence_setting hash chosen. once the image has been instantiated you can run this method without passing in any parameters by default it is executed with these settings:

settings: SETTINGS[:soft], sequence_settings: SEQUENCE_SETTINGS[:high_short], compress: true, speed: 84

example:

image.glitch_sequence

or with parameters, an output name can be passed in as well (string)

image.glitch_sequence({ settings: PixelDreamer::Constants::SETTINGS[:sharp], 
                        sequence_settings: PixelDreamer::Constants::SEQUENCE_SETTINGS[:high_long],
                        compress: false, speed: 42, output_name: 'image_glitched' })

the output name must only include the name of the output image not the file extension. this creates a sequence of of images that have been pixel sorted with the increments specified. the settings_hash can be pulled from the SETTINGS constant, defaults to SETTINGS[:soft]. the sequence_settings can be pulled from the SEQUENCE_SETTINGS constant, defaults to SEQUENCE_SETTINGS[:high_short]. compress defaults to true, copies and compresses input file and creates sequence from compressed file the fps is set by the speed which is in milliseconds, defaults to 84ms (12fps) the uri_helper method can be used to create the input uri

barrage

creates an image for each setting from the settings hash. quickest way to see how all of the settings effect the image supplied. once the image has been instantiated you can run this method without passing in any parameters by default it is executed with these settings: gif: false, compress: true, speed: 84

image.barrage

or with parameters, an output name (string) can be passed in as well

image.barrage({ gif: true, compress: false, speed: 42, output_name: 'image_glitched' })

the output name must only include the name of the output image not the file extension the uri_helper can be used to create the input uri

randomize

creates a series of images that are pixel sorted with randomized settings, the output is very hectic. once the image has been instantiated you can run this method without passing in any parameters by default it is executed with these settings: gif: false, compress: true, speed: 84, image_number: 10

image.randomize

or with parameters, an output name (string) can be passed in as well

image.randomize({ gif: trues, compress: false, speed: 42, image_number: 20, output_name: 'image_glitched' })

the output name must only include the name of the output image not the file extension the amount of images that are created are based on the image_number (integer)

gif

creates a gif using the images created from using either the randomize, glitch_sequence or barrage methods. once the image has been instantiated you can run this method without passing in any parameters by default it is executed with these settings: speed: 84, dither: DITHER_DEFAULTS, image_delay: IMAGE_DELAY_DEFAULTS

image.gif

or with parameters, an output name (string) can be passed in as well

image.gif({speed: 42, dither: PixelDreamer::Constants::DITHER_DEFAULTS, 
           image_delay: PixelDreamer::Constants::IMAGE_DELAY_DEFAULTS, output_name: 'image_gif'})

or

image.gif({speed: 42, dither: {active: false, number_of_colors: 200},
                image_delay: {active: false, image_to_delay: 1, delay_length: 1000}, output_name: 'image_gif'})

speed is used to set the length of time for each frame of the gif, it defaults to milliseconds

  • 12 fps: length of frame = 84 ms
  • 24 fps: length of frame = 42 ms
  • 30 fps: length of frame = 33 ms
  • 60 fps: length of frame = 17 ms the dither hash used to set the dither settings the image_delay hash is used to pause the sequence on an image for a set amount of time the patrol boolean is used to have the animation reverse at the end of it's cycle

uri_helper

creates a uri by adding the name to common paths

test = uri_helper('desktop', 'test.png')

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/13um45/pixel_dreamer.

License

The gem is available as open source under the terms of the MIT License.