Generate sprite images and stylesheets with plain PHP and GD2 (no 3rd party dependencies)
PHP extension GD2
Add this in your composer.json
{
"require": {
"nfq-alpha/sprite-bundle": "dev-master@dev"
}
}
and then run
php composer.phar update
new SpriteGenerator\SpriteGeneratorBundle(),
You have to configure your sprites by adding lines to config.yml
:
sprite_generator:
sprites:
spritename:
inDir: %kernel.root_dir%/../src/Resources/public/img/sprites/
outImage: %kernel.root_dir%/../src/Resources/public/img/sprite2.png
outCss: %kernel.root_dir%/../src/Resources/public/scss/_sprites2.scss
relativeImagePath: ../bundles/img/
padding: 5
spriteClass: sprite
cssFormat: sass
imagePositioning: one-column
imageGenerator: gd2
another_spritename:
inDir: %kernel.root_dir%/../src/Resources/public/img/sprites/
outImage: %kernel.root_dir%/../src/Resources/public/img/sprite2.png
outCss: %kernel.root_dir%/../src/Resources/public/scss/_sprites2.scss
relativeImagePath: ../bundles/img/
padding: 5
spriteClass: sprite_another
cssFormat: sass
imagePositioning: one-column
imageGenerator: gd2
Generate all your sprites :
$ php app/console nfq:sprite:generate
Generate one sprite :
$ php app/console nfq:sprite:generate spritename