Question

I'm trying to create a table of thumbnails for example 100 thumbnails 10x10 with GD Library. I saw that imagemagick has a montage function that would probably be useful but I'm wondering if GD library can do this as well.

I thought I could maybe do it by just outputting all of the images in a simple html table and converting that table to an image, but it appears that might not be possible. Any help or suggestions?

Was it helpful?

Solution

This is most certainly possible. You can resize images, as well as copy images into another image with GD. To find out more about resizing, check out this resize function I made: http://www.spotlesswebdesign.com/blog.php?id=1

But let's say your images are already resized to 10x10, and you had an array filled with 100 urls leading to different 10x10 gifs.

$montage_image = imagecreatetruecolor(100, 100);
$x_index = 0;
$y_index = 0;
foreach($array_with_100_10x10_gif_urls as $gif_image_url) {
    $current_image = imagecreategif($gif_image_url);
    imagecopy($montage_image, $current_image, $x_index * 10, $y_index * 10, 0, 0, 10, 10);
    imagedestroy($current_image);
    $x_index++;
    if ($x_index > 9) {
        $x_index = 0;
        $y_index++;
    }
}
// place code for saving the montage image as a file or outputting to teh browser here.
imagedestroy($montage_image);

OTHER TIPS

GD cant do that. Why not just use imagemagick?

EDIT: GD can do that, but you'd have to do it manually, there is no GD function comparable to imagemagick's montage.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top