Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. <?php
  2. function sprite_generator($dir) {
  3. global $img_width, $img_height, $fusion;
  4. $imgs = glob($dir . "/*.png");
  5. foreach($imgs as $img) {
  6. list($width, $height) = getimagesize($img);
  7. $img_height = $img_height + $height;
  8. $img_width = $img_width > $width ? $img_width : $width;
  9. };
  10. $sprite = imagecreatetruecolor($img_width, $img_height);
  11. if (is_array($imgs)) {
  12. foreach($imgs as $img) {
  13. static $position = 0;
  14. list($width, $height) = getimagesize($img);
  15. $fusion = imagecreatefrompng($img);
  16. imagecopymerge($sprite, $fusion, 0, $position, 0, 0, $img_width, $img_height, 100);
  17. $position = $position + $height;
  18. file_css($img);
  19. };
  20. };
  21. header('content-type: image/png');
  22. file_css($sprite);
  23. imagepng($sprite, 'sprite.png');
  24. imagedestroy($sprite);
  25. };
  26. sprite_generator('../css_generator/assets');
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement