PHPackages                             soundasleep/spritify - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. soundasleep/spritify

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

soundasleep/spritify
====================

A CSS processor to generate spritesheets

0.4.1(11y ago)01891[1 PRs](https://github.com/soundasleep/spritify/pulls)GPL-3.0PHPPHP &gt;=5.2.3

Since Apr 18Pushed 7y ago1 watchersCompare

[ Source](https://github.com/soundasleep/spritify)[ Packagist](https://packagist.org/packages/soundasleep/spritify)[ Docs](https://github.com/soundasleep/spritify)[ RSS](/packages/soundasleep-spritify/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (8)Used By (0)

spritify [![Build Status](https://camo.githubusercontent.com/c807e3eafb40de1b4c8cb6036522ba4495298ab1361cb6ea805e0fb8873d97cd/68747470733a2f2f7472617669732d63692e6f72672f736f756e6461736c6565702f73707269746966792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/soundasleep/spritify)
====================================================================================================================================================================================================================================================================================================

[](#spritify-)

A simple PHP script that can be used to process a CSS stylesheet, perform some basic optimisation, and generate a spritesheet of all sprites used in that stylesheet.

*NOTE* This project is very experimental - feel free to [report any issues or bugs](http://code.google.com/p/spritify/issues/list).

Requirements
------------

[](#requirements)

PHP, GD library (`apt-get install php5-gd`)

Features
--------

[](#features)

- Designed to be dropped into an existing project without requiring significant CSS changes
- Removes CSS comments
- Removes most unnecessary whitespace
- Generates spritesheets from PNG images less than a given size (default 32x32)
- Supports @media queries
- Supports full alpha PNG images
- Supports high resolution sprite scaling through `background-size`
- Disable spritify [for individual rules](http://code.google.com/p/spritify/source/detail?r=7) by using `x-background-sprite: false;`

Installing
----------

[](#installing)

Include [spritify](https://packagist.org/packages/soundasleep/spritify) as a requirement in your project `composer.json`, and run `composer update` to install it into your project:

```
{
  "require": {
    "soundasleep/spritify": "dev-master"
  }
}
```

You can then use *spritify* as part of your build script:

```
php -f vendor/soundasleep/spritify/spritify.php --input default.css --png img/all_sprites.png --output default-compiled.css

```

You can also use the new [grunt-contrib-spritify task](https://github.com/soundasleep/grunt-contrib-spritify) in your Gruntfile.

For example, [CryptFolio](https://cryptfolio.com) uses Spritify to transform [this stylesheet](https://github.com/soundasleep/openclerk/blob/master/site/css/default.scss) into a [compressed stylesheet](http://cryptfolio.com/styles/default.css) with a [PNG spritesheet](http://cryptfolio.com/img/default-sprites.png).

Limitations
-----------

[](#limitations)

- The input CSS needs to be valid.
- Uses very basic regular expressions, so will fail with strings that contain ;s, and does not support Unicode.
- Only supports spriting of PNG images, does not support GIF.
- The output CSS file needs to be in the same directory as the input CSS file.
- All images need to be relative and accessible relative to the CSS file (no Apache Aliases, etc).
- Sprited images within @media queries are not tested yet.
- Assumes background images are of one of the following formats:
    - `background: #123 url('foo');` (colours are added as another property 'background-color')
    - `background: url('foo');`
    - `background-image: url('foo');`
    - `background: url('foo') 0 0;`
    - `background: url('foo') 10px 20px;`
    - `background: url('foo') top 10px;`
    - `background-size: 16px 16px;`
- The following are not supported:
    - `background: #123 url('foo') bottom right;` (all other words are assumed to be 'top left')
    - `background: #123 url('foo') center center;` (something aligned 'center center' is ignored)
    - `background: url('foo') 0% 0%;`
    - `background: url('foo') 50% 100%;`
    - `background-size: 100%;`
    - `background-size: contain;`

Tests
-----

[](#tests)

Very basic tests are provided with phpunit. The source code for these tests are available in [tests/](tests/).

```
composer install
vendor/bin/phpunit

```

See Also
--------

[](#see-also)

- [CSSTidy](http://csstidy.sourceforge.net/)
- [OptiPNG](http://optipng.sourceforge.net/)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~52 days

Recently: every ~65 days

Total

6

Last Release

4143d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ebbec5ccc867054461adebb7c5b6312f8256f989ef96b124892e6e89724afdb?d=identicon)[soundasleep](/maintainers/soundasleep)

---

Top Contributors

[![soundasleep](https://avatars.githubusercontent.com/u/3889656?v=4)](https://github.com/soundasleep "soundasleep (39 commits)")

---

Tags

csspngbuildspritesspritesheet

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/soundasleep-spritify/health.svg)

```
[![Health](https://phpackages.com/badges/soundasleep-spritify/health.svg)](https://phpackages.com/packages/soundasleep-spritify)
```

###  Alternatives

[components/flag-icon-css

A curated collection of all country flags in SVG — plus the CSS for easier integration.

12.0k1.6M23](/packages/components-flag-icon-css)[matthiasmullie/minify

CSS &amp; JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns.

2.0k30.5M333](/packages/matthiasmullie-minify)[phing/phing

PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.

1.2k21.7M872](/packages/phing-phing)[scssphp/scssphp

scssphp is a compiler for SCSS written in PHP.

62827.7M220](/packages/scssphp-scssphp)[mexitek/phpcolors

A series of methods that let you manipulate colors. Just incase you ever need different shades of one color on the fly.

5003.6M18](/packages/mexitek-phpcolors)[wikimedia/less.php

PHP port of the LESS processor

12327.4M76](/packages/wikimedia-lessphp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
