How to deliver your images through Cloudinary with Perl

10th of July, 2012

Cloudinary is a cloud-based service for image management & manipulation. From their about page:

Use Cloudinary to: * Manage all your assets and web resources in the cloud. * Allow any web application, large or small, to enjoy modern web delivery platforms. * Completely remove the tedious tasks of locally managing web resources; instead, utilize the advanced features and industry best practices we always wished we had.

I personally feel that Cloudinary has lifted a burden from me, since I really don’t like to figure out the best Perl module to manipulate my images. I used to use Imagemagic for a while, but it simply isn’t that easy to use as Cloudinary.

I started out with the excellent documentation, discussed with Cloudinary using their online chat, and managed to pull together a Perl module I named Cloudinary. This module is based on top of the excellent Mojolicious framework, which allow you to communicate with Cloudinary in an async matter, which can be useful if you’re working with a lot of assets.

Main features


To run the examples below, you need to install the module first:

cpanm -n --sudo Cloudinary

Don’t have cpanm? Install cpanm using this command:

curl -L | perl - --self-upgrade

So how do you talk with Cloudinary? Here is an simple example which doesn’t even require an account:

use feature 'say';
use Mojo::Base; # or strict and warnings;
use Cloudinary;

my $cloudinary = Cloudinary->new(cloud_name => 'demo');
say $cloudinary->url_for('jhthorsen.jpg' => {
        type => 'facebook',
        width => 50,
        height => 100,

The code above will print this URL, which points to a scaled Facebook image of me:,w_50/jhthorsen.jpg

The destribution also includes a Mojolicious plugin which provide helpers which makes embedding images in your mojo templates easy:

%= cloudinary_image 'jhthorsen.jpg', { type => 'facebook' };

The above code will produce this output:


Try it out!

Register a free plan at Cloudinary try it out for your self. My module should allow you to take advantage of all the cool transformations which Cloudinary provides — and if not: Create an issue or send me a pull request on github.

More information can be found on metacpan:

Enjoy 🙂