Link to home
Start Free TrialLog in
Avatar of arkam chou
arkam chou

asked on

php create picture

Dear Expert,

Can I produce one image that mix from many source?
Ex:
1. layer one: background image
2. layer two: people image
3. layer three: date and time input user
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Yes.  You can use the GD library for this.  Start your learning adventures here:
http://php.net/manual/en/book.image.php
http://php.net/manual/en/ref.image.php

In PHP, one of the many uses of computer-generated images is to prepare a CAPTCHA test.  This article has some examples of image-based CAPTCHA generation.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_9849-Making-CAPTCHA-Friendlier-with-PHP-Image-Manipulation.html

This might be useful, too.
https://www.experts-exchange.com/articles/6554/Use-PHP-to-Make-an-Image-Thumbnail.html
Avatar of Julian Hansen
Depending on what your application is you can also achieve this in the client using CSS.

You can specify multiple backgrounds for an element, layer them, position them and scale them independently.

More info here

http://www.css3.info/preview/multiple-backgrounds/
Avatar of arkam chou
arkam chou

ASKER

sorry all that not clarify clearly. as the question, I want to produce image file that make up from many layer and text.
Can you give us an example of what you are trying to achieve

- What is the application - what is this for?
- Example image of what you want to achieve.

There could be various answers to this question depending on exactly what you want to do.
I want to generate image file. I have three type of source to generate many file as below:
1. I choose many image file as layer1 (background)
2. I choose many image file as layer2 (logo image)
3. I input many date and time as layer3

ex: I input 100 difference date and time. so it will generate 100 image file by combine  random background (layer1), logo(layer2) and each input date.
Yes, you can do that.  But this is not really a question with any succinct answer, so much as a request for application development, and for that you may want to hire a professional developer.

I should have added this link to the articles about image processing:
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_10065-Adding-a-Watermark-to-an-Image.html

If you read those three articles and still have questions, please post back and tell us specifically what you do not understand.  We'll be glad to help.
Ok, but what do you want to do with the output?
Without knowing how you intend to use your final image difficult to give you any direction.

Here is a simple script to demonstrate dynamically creating a composite image with overlay text by selecting different items from a radio list

http://www.marcorpsa.com/ee/t797.html
I not yet complete read link from Ray Paseur, but seeing last link of JulianH, this example is nearly complete. after overlay backgrounds, foregrounds and text, it will produce window image file.
The process of create image file is not one by one. I need to choose many backgrounds, foregrounds and list of test from excel then generate file by random backgrounds, foreground and loop with text that collect from excel.
Are you able to proceed with the example or do you require more input from us?
for my question is require more input from you but I will try myself if I can create file from your last example.
or my question is require more input from you
Can you be a bit more specific as to what exactly you need from us. From your second to last post you seemed to be saying the example was mostly there but did not say what was still required.
I want to create image files. The image file is mixing with three layer:
layer1: is background
layer2: is foreground
layer3: is text

the layer1 has many image in server
the layer2 has many image in server
the layer3 is input by user (it can input one by one or take list of text from excel or text file

when create image file,  it will random layer1, layer2 from server with the layer3 that input by user.
@Sokrada - that is basically the same information you gave us at the beginning.

You have not told us what you are going to do with this image - how are your users going to view / interact with it.
Is this going to be viewed in a web page?
Do they need to download a copy or only view?

What do you still need that was not in the example posted.
Please show us your test data set and show us the code you've tried to use to accomplish these tasks.
create image files (download a copy)
What will be done with the copy - is it viewed or saved.

In this comment  https://www.experts-exchange.com/questions/28682644/php-create-picture.html?anchorAnswerId=40805447#a40805447 you said
but seeing last link of JulianH, this example is nearly complete
I have twice asked for clarification on what you still need this example to do.
because the image on this example cannot save as image file

http://www.marcorpsa.com/ee/t797.html
Now we are finally getting somewhere.

So your requirement is to create a composite image as a .JPG (or .PNG) made up of a random selection of background, foreground and date layers (images and text).

This must be saved to a new image [WHAT NAMING CONVENTION?] which is then returned to the browser?

Is this correct?
yes. I want create new image file by mixing these three layer.
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dear JulianH,

It alert message "Failed ...".
It alert message "Failed ...".
@sokrada, if you want to get the best out of this forum you need to supply us with good information.

Your last post tells us nothing at all about your problem - what failed - where? There are no alert's in the sample posted.

Please can you be a bit more descriptive in your posts.
Dear JulianH,

Please help to find attachment that I combine html and php. After I click button "SaveImage", it show message "Failed..".
background.jpg
Login.png
system.png
I have loaded those to the sample page.

Attached image was saved from that page
User generated image
Dear JulianH,

sorry forgot attach you with this code. I think may be have something with me. could you check this attachment.
saveImage.php
That code works perfectly on my side so I would imagine that something like the font file not being in the same folder as your script file is the problem. As I mentioned in my earlier post the font file must either be referred to by its absolute path or it must be in the same folder.