CSS-SpriteBuilder
view release on metacpan or search on metacpan
$builder->build(config => 'config.xml');
$build->write_css('sprite.css');
DESCRIPTION
This module generate CSS sprites with one of these modules:
Image::Magick or GD.
It has many useful settings and can be used for sites with complex
structure.
METHODS
new(<%args>)
my $builder = CSS::SpriteBuilder->new(<%args>);
Create instance.
Valid arguments are:
* source_dir [ = undef ]
Specify custom location for source images.
* output_dir [ = undef ]
Specify custom location for generated images.
* image_quality 0..100 [ = 90 ]
Specify image quality for generated images (for JPEG only).
* max_image_size [ = 65536 ]
Specify max size of images that will be used to generate a sprite.
* max_image_width [ = 2000 ]
Specify max width of images that will be used to generate a sprite.
* max_image_height [ = 2000 ]
Specify max height of images that will be used to generate a sprite.
* max_sprite_width [ = 2000 ]
Specify max width of sprite. When sprite has no free space, than
creates a new sprite with addition of a suffix to the sprite name.
Opera 9.0 and below have a bug which affects CSS background offsets
less than -2042px. All values less than this are treated as -2042px
exactly.
* max_sprite_height [ = 2000 ]
Specify max height of sprite.
* margin [ = 0 ]
Add margin to each image.
* transparent_color [ = undef ]
Set transparent color for image, for example: 'white', 'black', ....
* is_background [ = 0 ]
If is_background flag is '0' will be generated CSS rule such as:
'width:XXXpx;height:YYYpx;'.
* layout [ = 'packed' ]
Specify layout algorithm (horizontal, vertical or packed).
* css_selector_prefix [ = '.spr-' ]
Specify CSS selector prefix. For example, for an image
"img/icon/arrow.gif" will be generated selector such as
".spr-img-icon-arrow".
* css_url_prefix [ = '' ]
Specify prefix for CSS url. For example: background-image:
url('css_url_prefixsample_sprite.png')
* is_add_timestamp [ = 1 ]
If parameter set to '1' than timestamp will be added for CSS url.
For example: background-image: url('sample_sprite.png?12345678')
build(<%args>)
Build sprites.
$builder->build(<%args>);
This method returning structure like:
{
'sample_sprite_1.png' => [
{
'y' => 0,
'width' => 32,
'selector' => '.spr-small-add',
'is_background' => 0,
'x' => 0,
'height' => 32,
'image' => 'small/Add.png',
'repeat' => 'no'
},
...
],
...
}
Valid arguments are:
* sprites
Specify sprite list.
$builder->build(
sprites => [
{
file => 'horizontal_%d.png',
( run in 0.748 second using v1.01-cache-2.11-cpan-39bf76dae61 )