NAME

CSS::SpriteMaker::Simple - generate CSS sprites from a bunch of images

SYNOPSIS

    say CSS::SpriteMaker::Simple->new->spritify('pics', 'pic1.png')->css;

    # or

    CSS::SpriteMaker::Simple->new
        ->spritify('pics', 'pic1.png')->spurt('sprite.css');

    ...
        <span class="sprite s-FILENAME-OF-PIC"></span>

      <link rel="stylesheet" property="stylesheet" href="sprite.css">
    </body>
    </html>

DESCRIPTION

Generate a CSS sprite using given image files. The result is a a single chunk of CSS code, with images base64 encoded into it.

This code was plucked from a project I was working on and simply quickly packaged into a CPAN distro. As such, it currently lacks tests. Patches are definitely welcome.

METHODS

new

    my $s = CSS::SpriteMaker::Simple->new;

Creates and returns a new CSS::SpriteMaker::Simple object. Takes no arguments.

spritify

    $s->spritify( qw/list of dirs with pics or pics/ );
    $s->spritify( qw/list of dirs with pics or pics/, [qw/ignore these/] );

Returns its invocant. Takes a list of paths and searches them for pics to use as sprites. The last element can be an arrayref, in which case, this will be a list of filenames (no directory portion) that will be ignored.

Will croak if no paths are given or it has trouble creating the temporary directory to assemble the sprite in.

css

    say $s->css;

Returns CSS code of the sprite. Must be called after a call to "spritify"

spurt

    say $s->spurt('sprite.css');

Write CSS code of the sprite into a file. Must be called after a call to "spritify"

SEE ALSO

Mojolicious::Plugin::AssetPack

REPOSITORY

BUGS

To report bugs or request features, please use https://github.com/zoffixznet/CSS-SpriteMaker-Simple/issues

If you can't access GitHub, you can email your request to bug-CSS-SpriteMaker-Simple at rt.cpan.org

AUTHOR

LICENSE

You can use and distribute this module under the same terms as Perl itself. See the LICENSE file included in this distribution for complete details.