yes you can do this in php.
since it sounds like you have some programming exp, ill point you to some reading to learn about image manipulation.
http://php.net/gd that is the extension for creating and manipulating images
http://php.net/imagecopyresized the function for putting one image on another.
http://php.net/imagecreate creates a new pallete
also see the imagecreatejpeg imagecreatepng for creating images from an existing one.
this is a code sample from a php book, beginning php4 programming, by wrox press. wankyu choi et al
<?php
//map.php
Header("Content-type: image/jpeg");
$image = ImageCreateFromJPEG("island.jpg");
$icon = ImageCreateFromJPEG("pin.jpg");
$width = ImageSX($icon);
$height = ImageSY($icon);
ImageCopyResized($image,$icon,174,200,0,0,$width,$height,$width,$height);
ImageJPEG($image);
ImageDestroy($image);
?>
that will take the little image pin.jpg and place it on island.jpg. sorry i dont have the images but im sure you can tweak it a bit after some practice with php.