Mount or collage with the GD library

I am trying to create a thumbnail table, such as 100 10x10 thumbnails with the GD Library. I saw that imagemagick has a editing function that would probably be useful, but I'm wondering if the GD library can do it.

I thought I could do this by simply outputting all the images in a simple html table and converting this table to an image, but it seems like this might not be possible. Any help or suggestions?

+3
source share
2 answers

It is certainly possible. You can resize images as well as copy images to another image using GD. To learn more about resizing, check out this resizing function I did: http://www.spotlesswebdesign.com/blog.php?id=1

But let's say that 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);
+3
source

I can’t do it. Why not just use imagemagick?

EDIT: GD can do this, but you have to do it manually, there is no GD function comparable to graphic editing.

+1
source

Source: https://habr.com/ru/post/1783953/


All Articles