# Bitmap -\> GIF/PNG/JPG

**URL:** <https://www.ruby-forum.com/t/bitmap-gif-png-jpg/104672>\
**Category:** Ruby\
**Created:** [May 21, 2007, 1:28pm UTC](https://www.ruby-forum.com/t/bitmap-gif-png-jpg/104672 "2007-05-21T13:28:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike343](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike343](https://www.ruby-forum.com/u/mike343)\
**Post date:** [May 21, 2007, 1:28pm UTC](https://www.ruby-forum.com/t/bitmap-gif-png-jpg/104672/1 "2007-05-21T13:28:16Z")

</div>

Hi,

Can anyone please recommend a package for generating images from a  
bitmap vector. e.g. If I have an list of integers, each representing a  
colour on the bitmap, and I want to build a GIF from it (along with some  
other meta-info like dimensions).

The main options seem to be RMagick and RCairo, but neither seems to  
take a bitmap input. I’d have to create a blank canvas and draw each  
pixel. Do-able but inefficient.

Thanks,  
Michael

---

<div class="post-metadata">

**Author:** ![mike343](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike343](https://www.ruby-forum.com/u/mike343)\
**Post date:** [May 21, 2007, 2:00pm UTC](https://www.ruby-forum.com/t/bitmap-gif-png-jpg/104672/2 "2007-05-21T14:00:20Z")

</div>

Michael M. wrote:

> Hi,
> 
> Can anyone please recommend a package for generating images from a  
> bitmap vector. e.g. If I have an list of integers, each representing a  
> colour on the bitmap, and I want to build a GIF from it (along with some  
> other meta-info like dimensions).
> 
> The main options seem to be RMagick and RCairo, but neither seems to  
> take a bitmap input. I’d have to create a blank canvas and draw each  
> pixel. Do-able but inefficient.

Check out Magick::Image#import\_pixels:  
[RMagick 1.15.0: class Image (instance methods, part 2)](http://www.simplesystems.org/RMagick/doc/image2.html#import_pixels). If  
the input pixels are in a string buffer this is an extremely fast  
method. If the pixel data are in an array it’s still faster than drawing  
each pixel separately.

If your pixel data are in a file you may be able to simply describe it  
as being in “RGB” or “RGBA” format, in which case RMagick can convert it  
for you. See [ImageMagick – Image Formats](http://www.imagemagick.org/script/formats.php).
