Create CSS-sprite of 1000 images using PHP and XML

host-business

New Member
I have a XML file with approximately 1000 image-urls. I want to create a sprite of all the images using PHP.
  • The XML file is about 30 MB in size
  • The images are about 15kb in size
How can I get it done?Here is my code (I get Fatal error: Allowed memory size ...):\[code\]<?php$dest = imagecreatefromjpeg('15000x2000.jpg');$increasing_width = 0;$increasing_height = 0;$xmldata = 'http://stackoverflow.com/questions/11394145/1000-images.xml';$open = fopen($xmldata, 'r');$content = stream_get_contents($open);fclose($open);$xml = new SimpleXMLElement($content);foreach ($xml->xpath('//image') as $image) { $src = http://stackoverflow.com/questions/11394145/imagecreatefromjpeg('test/' . $image->picture->attributes() . '.jpg'); if ($increasing_width == '15000') { $increasing_width = '0'; $increasing_height += 200; } imagecopymerge($dest, $src, $increasing_width, $increasing_height, 0, 0, 150, 200, 100);}imagejpeg($dest, '15000x2000.jpg');?>\[/code\]
 
Back
Top