here imagick works for image which are stored in server.. but i dont know how to work if i replace with remote url in $paths array
$background = new Imagick('back.jpg');
$paths = array(
"img/1.jpg",
"img/2.jpg",
"img/3.jpg",
"img/4.jpg",
);
$images = new Imagick($paths);
foreach($images as $image){
$image->thumbnailImage($width, NULL);
$background->compositeImage($image, Imagick::COMPOSITE_OVER, $x ,$y );
}