I came across this requirement to process multiple images and text to single final image, while working on a custom product in an eCommerce site. The requirement is, via multiple custom options fields, user would choose different options and the product image gets customized. for eg. cover type, ribbon, uploads logo/image and text were the field, user would input.

On the interface level, i managed to obtain by positioning images one after another and also same with the text, but at the end, i was asked to processed all those and create one single image. I captured those images and text positioning with jquery-UI (on dragstop, as the text and images are made to resizable and draggable). Ok, now let’s focus on blog major task.


– to enable PHP GD library

In localhost i have xampp installed. and i can enable that from php.ini file. (I uncommented extension=php_gd2.dll and restarted xampp server to enable gdlibrary in my local server)

Sample Images : I am taking these three images below (img1.png,im2.png & img3.png)




I am creating a php file ‘create-image.php’ with a function ‘createimageinstantly’

In the codes below I have created a base image of 600×600 with gd-inbuild function imagecreatetruecolor and directories path to those images.

Merging images

Now defining the background of the images, i want to create white background for the processed image. With the gd-inbuild functions imagecreatefrompng & imagecopyresized, i am merging those images.

Adding text

with the method imagettftext we are able to add text on the merged images above.

Final processing

the method imagepng allows us to create final image with those three images merged above with text. whereas the imagedestroy would free the memory.

The result image merged :


the final code


A friend of mine was talking about his idea of generating custom Tshirts, where users would input texts or images to upload from the user interface and to deliver as according to the user customizes. So, there you go. Where as my requirement was to create custom diploma covers and the result is what I obtained. Cheers !!

The college logo used here is the copyright of Austin College.

Suman K.C

eCommerce Developer, writes about stuff related to eCommerce development. Currently based in Kathamandu, loves reading about startups & new technology, introvert nature, fond of traveling & playing volleyball.

More Posts - Website

Follow Me:
LinkedInGoogle Plus