0

我有一个包含大约 1000 个图像 URL 的 XML 文件。我想使用 PHP 创建所有图像的精灵。

  • XML 文件大小约为 30 MB
  • 图片大小约为 15kb

我怎样才能完成它?

这是我的代码(我收到致命错误:允许的内存大小...):

<?php

$dest              = imagecreatefromjpeg('15000x2000.jpg');
$increasing_width  = 0;
$increasing_height = 0;

$xmldata = '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 = 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');

?>
4

1 回答 1

1
于 2013-12-23T22:35:03.557 回答