$src
スクリプトにはいくつかの改善がある可能性があります。現在、塗りつぶしよりも多くの画像がある場合、タイルのレンダリングは正しく機能しませんwidth
。
できるだけ多くのタイルを処理するようにコードを調整しました。
<?php
$width = 320; // pick size
$height = 320; // pick size
$dest = imagecreatetruecolor($width, $height);
// I just added the same 3 pictures just to test the overflow
$src[] = imagecreatefrompng('otter.png');
$src[] = imagecreatefrompng('fox.png');
$src[] = imagecreatefrompng('opals.png');
$src[] = imagecreatefrompng('otter.png');
$src[] = imagecreatefrompng('fox.png');
$src[] = imagecreatefrompng('opals.png');
$src[] = imagecreatefrompng('otter.png');
$src[] = imagecreatefrompng('fox.png');
$src[] = imagecreatefrompng('opals.png');
$src[] = imagecreatefrompng('otter.png');
$src[] = imagecreatefrompng('fox.png');
$src[] = imagecreatefrompng('opals.png');
$src[] = imagecreatefrompng('otter.png');
$src[] = imagecreatefrompng('fox.png');
$src[] = imagecreatefrompng('opals.png');
$thumbnailWidth = 32; // Should be deduced from the thumbnails
$imagesPerRow = $width / $thumbnailWidth;
// Copy and merge
for($i=0;$i<count($src);$i++)
{
// Using this code, your thumbnails will overflow to the next row
$row = floor($i / $imagesPerRow);
$column = $i % $imagesPerRow;
imagecopymerge($dest, $src[$i], 32*$column, 32*$row, 0, 0, 32, 32, 100);
}
// Output and free from memory
header('Content-Type: image/png');
imagepng($dest);
imagedestroy($dest);
for($ii=0;$ii<count($src);$ii++){
imagedestroy($src[$ii]);
}
?>
これにより、次の結果が得られます。
