Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function sprite_generator($dir) {
- global $img_width, $img_height, $fusion;
- $imgs = glob($dir . "/*.png");
- foreach($imgs as $img) {
- list($width, $height) = getimagesize($img);
- $img_height = $img_height + $height;
- $img_width = $img_width > $width ? $img_width : $width;
- };
- $sprite = imagecreatetruecolor($img_width, $img_height);
- if (is_array($imgs)) {
- foreach($imgs as $img) {
- static $position = 0;
- list($width, $height) = getimagesize($img);
- $fusion = imagecreatefrompng($img);
- imagecopymerge($sprite, $fusion, 0, $position, 0, 0, $img_width, $img_height, 100);
- $position = $position + $height;
- file_css($img);
- };
- };
- header('content-type: image/png');
- file_css($sprite);
- imagepng($sprite, 'sprite.png');
- imagedestroy($sprite);
- };
- sprite_generator('../css_generator/assets');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement