# Thumbnailer 0.1

**URL:** <https://www.ruby-forum.com/t/thumbnailer-0-1/115249>\
**Category:** Ruby\
**Created:** [September 22, 2007, 1:09pm UTC](https://www.ruby-forum.com/t/thumbnailer-0-1/115249 "2007-09-22T13:09:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ilmari\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a587f6/32.png) [@Ilmari\_H](https://www.ruby-forum.com/u/Ilmari_H)\
**Post date:** [September 22, 2007, 1:09pm UTC](https://www.ruby-forum.com/t/thumbnailer-0-1/115249/1 "2007-09-22T13:09:56Z")

</div>

tarball: [http://dark.fhtr.org/repos/thumbnailer/thumbnailer-0.1.tar.gz](http://dark.fhtr.org/repos/thumbnailer/thumbnailer-0.1.tar.gz)  
git: [http://dark.fhtr.org/repos/thumbnailer](http://dark.fhtr.org/repos/thumbnailer)

example thumbnails:  
[http://dark.fhtr.org/repos/thumbnailer/example\_thumbnails/](http://dark.fhtr.org/repos/thumbnailer/example_thumbnails/)

## Description

This package `Thumbnailer' comes with a library called `thumbnailer’  
and  
a program called `thumbnailer’.

The thumbnailer library uses external thumbnailing programs to create  
an  
image of wanted size from a given file. Supported output formats are  
PNG  
and JPEG.

As my own use for the thumbnailer is as a source of mipmapped  
textures,  
the default behaviour is to create a full-size thumbnail. E.g. if you  
have a 3039x2014 camera raw, you’ll get a 3039x2014 jpeg or png out.  
For  
PDFs and videos, the default size is 2048px on the longest side.

## Usage

# create a full-size jpeg thumbnail

$ thumbnailer foo.png foo.jpg  
$ thumbnailer bar.avi foo.jpg

# create a png thumbnail that’s scaled to fit in a 1024x1024 square

$ thumbnailer -s 1024 foo.pdf foo\_thumb.png

irb\> require ‘thumbnailer’

# fit the jpg inside a 256x256 square

irb\> Thumbnailer.thumbnail(“foo.png”, “foo\_thumb.jpg”, 256)

# page five of the pdf

irb\> Thumbnailer.thumbnail(“bar.pdf”, “bar\_thumb.png”, 2048, 5)

# take the main thumbnail at 30 seconds into the video

irb\> Thumbnailer.thumbnail(“qux.avi”, “qux\_thumb.jpg”, 1024, 30)

## List of supported formats

Images  
Most image formats. PSDs probably not too accurately.

```
Successfully tested:
  jpg, png, gif, psd, orf, nef, dng, crw, pef, tif, xpm, ppm, tga, 

```

svg

```
Uses image icon:
  xcf

```

Videos  
Anything mplayer / ffmpeg can play.

```
Successfully tested:
  mkv, flv, avi, mpg, mov

```

Audio  
Anything mplayer can play.

```
The audio thumbnailing system is a wee bit peculiar. It relies
on a Tcl/Tk app to create a waveform and spectrogram of the audio.
And that requires an X server, of which Xvfb is the best for this
purpose. See Requirements.

Successfully tested:
  mp3, wav, m4a, flac, ra, ogg, wma

Uses audio icon:
  ape

```

Documents  
The document thumbnailer first converts the document into a PDF,  
then  
thumbnails the PDF. The PDF conversion requires ooffice for office  
documents.

```
The HTML thumbnailer uses GtkMozEmbed, which requires an X server. 

```

So it  
uses yet another Xvfb server for it. See Requirements.

```
Successfully tested:
  pdf, html, ps, ps.gz, txt, sxi, ppt, odp

```

Others  
Thumbnailer uses a mimetype-specific icon from its icons-directory.  
If there’s an SVG icon, the SVG icon will be used. Otherwise a PNG  
icon  
will be used.

```
Successfully tested:
  directory, bz2, torrent

```

## Requirements

- Ruby 1.8

- Metadata library for Ruby  
[http://dark.fhtr.org/repos/metadata](http://dark.fhtr.org/repos/metadata)

- Tons of image converter programs and shared-mime-info.  
[shared-mime-info](http://freedesktop.org/wiki/Software/shared-mime-info)  
List of debian packages:  
xvfb  
[openoffice.org](http://openoffice.org)  
python-uno  
libimlib2-ruby  
netpbm  
librsvg2-bin  
paps  
gs-common  
imagemagick  
mplayer  
ffmpeg  
libsnack2  
poppler-utils (v0.6, [http://poppler.freedesktop.org/](http://poppler.freedesktop.org/))

- You need the latest version of dcraw to handle some camera raw  
images.  
[http://cybercom.net/~dcoffin/dcraw/](http://cybercom.net/~dcoffin/dcraw/)

- You need unoconv for thumbnailing office documents:  
[http://dag.wieers.com/home-made/unoconv/](http://dag.wieers.com/home-made/unoconv/)

- For HTML thumbnailing, you need an X server on display :15

- For audio thumbnailing, you need an X server on display :16

## Install

De-compress archive and enter its top directory.  
Then type:

($ su)  
# ruby setup.rb

These simple step installs this program under the default  
location of Ruby libraries. You can also install files into  
your favorite directory by supplying setup.rb some options.  
Try “ruby setup.rb --help”.

## License

GPL v3
