I am trying to create a dynamic image that will be created fro开发者_开发百科m PHP using GD... What I need to do is be able to specify the layering of one image over another. The images are supposed to overlap slightly and get smaller as you move towards the right of the image... however the only way I can get php to render the images to the left on top of the ones to the right is by reversing the script.
I would like some sort of way to be able to add the images 1 by 1 to the picture from left to right but having the image on the left overlap the one on the right....
Exactly like z-index in PHP, is there a way to do this?
Image manipulation in GD is additive, AFAIK. If you are going to manipulate an image (in your case, create a composite image), then you need to start with a base (maybe a solid background) then add pieces to it.
You can get the effect that you want by performing one of the two procedures:
- take the "left to right" stack that you have and reverse it, applying images to the composite from right-to-left.
- go "left-to-right" and calculate which part of each image will show around the previous image (to its left). This method is significantly more complicated because the image on the "lower z-index" can show around up to four corners of the image to it's left.
精彩评论