Create your main image and consider it your "canvas."
From there, use imagecopy () to copy smaller images to the canvas image.
See this for example:
<?php header('Content-Type: image/jpg'); $canvas = imagecreatetruecolor(304, 179); $icon1 = imagecreatefromjpeg('icon.jpg'); $icon2 = imagecreatefromjpeg('icon2.jpg'); // ... add more source images as needed imagecopy($canvas, $icon1, 275, 102, 0, 0, 100, 100); imagecopy($canvas, $icon2, 0, 120, 0, 0, 100, 100); // ... copy additional source images to the canvas as needed imagejpeg($canvas); ?>
In my example, icon.jpg is a 100x100 image that I put on the canvas, so its upper left corner is at 275, 102 in the canvas, which cuts off the right side.
Edit
I adjusted the code to be more like what you are doing.
source share