Hello again,

Following on from my last post about images, here’s a really fast Perl thumbnail generator, so you can create thumbnail images on the fly in your CGI without lots of offline messing about.

It’s Image::Epeg, which relies on having epeg installed on your system. Here’s how it’s used to create a 100×100 pixel image file:

use Image::Epeg qw(:constants);
...
my $epg = new Image::Epeg( "/path/to/large_$image_name" );
$epg->resize( 150, 150, MAINTAIN_ASPECT_RATIO );
$epg->write_file( "/path/to/thumbnails/$image_name" );

And here’s how to install epeg (not obvious… see koofr’s github site for more info) :

$ sudo apt-get install build-essential cmake nasm
$ git clone https://github.com/koofr/epeg.git
$ cd epeg
$ mkdir build
$ cd build/
$ cmake
$ sudo make install
$ sudo apt install libjpeg-dev
$ sudo cpan install Image::Epeg

As koofr says : “…insanely fast JPEG/JPG thumbnail scaling with the minimum fuss and CPU overhead …”.

You can see how I used it in my tagski code.

So, when you upload images you can make thumbnails as they are uploaded to make things that much easier…!

CheersO,

~andy~