Add multiple image in a single image in php?

147 views Asked by At

Current Situation I have a single image (say original image), eight other small annotation images (say A,B,C....). I have a JSON in my database which stores the position of my annotation images. Any annotation image can be used multiple times.

My requirement I have to add annotation image on my original image. The annotation image can be added upto 1000 times with different coordinates (means 8 images need to be added 1000 times on my original image).This final image will be sent in a email with further business logic.

What i have currently implemented and my issue I am trying to add single annotation on my original image, then saving it, then opening it again, then adding another annotation, and this cycle repeats 1000 times. This slows down my Azzure server and hangs it and takes upto 8 minutes for my mobile users to get response. As php does not support multi threading i need to generate this image (with 1000 annotations) in a single cron and hence it delays my response for the request.

Algorithm that i have implemented Let me explain you whole flow how it is working now..

I have one image of apartment and i assign one task to my worker on particular x-y coordinate of image. when i assign task 1 i create one image with no 1 and set on original image of apartment on that particular x-y coordinate and generate new image with added that annotation no 1 .

Now assume i assigned 1000 task to that single worker so same process will repeat 1000 time and total 2000 images generate.

let me know if still you are not getting or any query.

Thanks in advanced

1

There are 1 answers

0
Mark Setchell On

I really don't understand this confusing question, but I think I can contribute towards an answer. Loading, annotating and resaving any image 1,000 times will firstly take forever, and secondly, if it is lossily encoded, destroy the quality.

I think the correct way to do this is to create an MVG script with ALL the commands in it and run the script once to load the image a single time, apply the 1,000 edits and then resave it once.

As you have no concrete examples, or images, all I can do is point you to here and hope you can see what I mean. Basically you will create a script that contains a line like this for each paste of each image onto the original:

image src-over x1,y1 'image1.jpg'
image src-over x2,y2 'image2.jpg'
...