can i place an image on another image using php?
image on top of image
The first short answer is: Yes.
The second short answer is: search google for how to do it
The third short answer is that in most cases you might aswel use HTML/CSS to do the job.
(the fourth short answer is: i will help you with the HTML/CSS if you want)
The second short answer is: search google for how to do it
The third short answer is that in most cases you might aswel use HTML/CSS to do the job.
(the fourth short answer is: i will help you with the HTML/CSS if you want)
yes i would like you to help me
btw can a text box or a drop list be able to do so ?
btw can a text box or a drop list be able to do so ?
Yes, anything can be put ontop of something else.
Here are instructions on 2 ways to do this:
(if you use this, and the object goes ontop of something else, it will automatically go over, not under)
Nr 1: Absolute Positioning
This is the easiest method to understand. Basically, absolute positioning lets you place an object precisely where you want it.
Inside your element (<img>,<div>,<select>,etc...) place the following code:
The two 50px's need to be changed to #px where # is the amount of pixels you want the object to be away from the left/top edge of the screen (viewport)*
Nr 1: Relative Positioning
This is slightly more difficult to understand, however much better for many purposes:
Inside your element (<img>,<div>,<select>,etc...) place the following code:
The two 50px's need to be changed to #px where # is the amount of pixels you want the object to be "nudged" away from its current position - just do some testing to fid out how it works.
* = if you add an element which is positioned absolutely or relatively around your absolutely positioned object, it will calculate its position using the edge of the surrounding object instead of the screen (viewport)
Hope this helped...
Here are instructions on 2 ways to do this:
(if you use this, and the object goes ontop of something else, it will automatically go over, not under)
Nr 1: Absolute Positioning
This is the easiest method to understand. Basically, absolute positioning lets you place an object precisely where you want it.
Inside your element (<img>,<div>,<select>,etc...) place the following code:
| Code: |
| style="position: absolute; top: 50px; left: 50px;" |
The two 50px's need to be changed to #px where # is the amount of pixels you want the object to be away from the left/top edge of the screen (viewport)*
Nr 1: Relative Positioning
This is slightly more difficult to understand, however much better for many purposes:
Inside your element (<img>,<div>,<select>,etc...) place the following code:
| Code: |
| style="position: relative; top: 50px; left: 50px;" |
The two 50px's need to be changed to #px where # is the amount of pixels you want the object to be "nudged" away from its current position - just do some testing to fid out how it works.
* = if you add an element which is positioned absolutely or relatively around your absolutely positioned object, it will calculate its position using the edge of the surrounding object instead of the screen (viewport)
Hope this helped...
err.. i think u need to set the tag like this <div style="position:absolute;z-index:9999" ><img src="xxxx"></div>
z-index: <- the more higher value then it will in the most top.
z-index: <- the more higher value then it will in the most top.
| janszmatt wrote: |
| can i place an image on another image using php? |
Okay, once you've created an image resource in your PHP script, you need to have another image resource to copy it from. You can create the second image resource using imagecreate(width, height) (for an image from scratch), imagecreatefrompng(filename) (for a .png image file), imagecreatefromgif(filename) (for a .gif image file), imagecreatefromjpeg(filename) (for a .jpg or .jpeg file), or imagecreatefromwbmp(filename) (for a .wbmp file).
Then, you can use imagecopy() to copy image 2 onto image 1. Here is an example.
| Code: |
| $img1 = imagecreate(900, 600);
$img2 = imagecreatefrompng('images/image2.png'); imagecopy($img1, $img2, 4, 5, 0, 0, imagesx($img2), imagesy($img2)); imagepng($img1); |
This example would create an image with the size 900x600, and copy the file images/image2.png onto the new image. It tells it to copy it to the coordinates 4, 5; and find the image's width and height automatically (using imagesx() and imagesy()).
Hope this clears things up for you
| Philip wrote: |
| err.. i think u need to set the tag like this <div style="position:absolute;z-index:9999" ><img src="xxxx"></div>
z-index: <- the more higher value then it will in the most top. |
The z-index property goes from front to back, meaning that it specifies depth. Higher depth means it will be back farther.
And as he is asking about PHP and not (X)HTML or CSS, I believe he is asking about actual PHP functions, not HTML or CSS stylings. Either that, or he's in the wrong forum.
| bladesage wrote: |
| ...
And as he is asking about PHP and not (X)HTML or CSS, I believe he is asking about actual PHP functions, not HTML or CSS stylings. Either that, or he's in the wrong forum. |
@Bladesage:
If you read my first post, and his second it would appear (I certainly think so) that he doesn't really know whether he wants php or html/css.
Helping him the html/css way surely isnt a problem, even though this is the php forum?
