PHP Classes

CSS sprite class: Generate sprite images and CSS to use image styles

Recommend this page to a friend!
  Info   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum (3)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 59%Total: 1,498 All time: 2,615 This week: 455Up
Version License PHP version Categories
css-sprite-class 1.0.0GNU General Publi...5.0HTML, PHP 5, Graphics


This class can be used to generate sprite images and CSS to use image styles to use the sprites in Web pages.

It can take a list of images and generates a single sprite image with all the images inside.

The class can also generate CSS style definitions to use in Web pages that need to use the images from the generated sprite image.

Innovation Award
PHP Programming Innovation award nominee
October 2010
Number 2

Prize: One book of choice by Packt
Web pages with many images force the browser to make too many requests to the Web server.

An alternative solution to reduce the number of requests consists in assembling several images into a single sprite image. Then use CSS styles that define how to clip each image from the sprite and use the image in the Web pages.

This class implements a PHP solution to assemble sprite from a list of images and the necessary CSS styles to use the images in the pages.

Manuel Lemos
Picture of Arturs Sosins
  Performance   Level  
Name: Arturs Sosins <contact>
Classes: 22 packages by
Country: Latvia Latvia
Age: 36
All time rank: 511 in Latvia Latvia
Week rank: 53 Down1 in Latvia Latvia Equal
Innovation award
Innovation award
Nominee: 13x

Winner: 2x

  Files folder image Files  
File Role Description
Files folder imageexamples (3 files)
Files folder imagetest_images (3 files)
Plain text file css_sprite.class.php Class Main class file

  Files folder image Files  /  examples  
File Role Description
  Accessible without login Plain text file css_code_example.php Example CSS code generation example
  Accessible without login Plain text file download_sprite_example.php Example CSS sprite forcing download example
  Accessible without login Plain text file image_output_example.php Example CSS sprite output example

  Files folder image Files  /  test_images  
File Role Description
  Accessible without login Image file elephpant.png Icon Test png file
  Accessible without login Image file php.gif Icon Test gif file
  Accessible without login Image file php.jpg Icon Test jpg file

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:2,615
This week:455Up
User Ratings User Comments (1)
 All time
Very nicely done.
13 years ago (Tom Carnevale)