tags:

views:

34

answers:

1

Hey there,

I am trying to create a dynamic image that will be created from 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?

Thanks in advance :)

+1  A: 

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.
Oxyrubber
Yea that's what I'm doing right now lol... I was wondering if maybe there was an easier way to do it... right now I have an array of images which is reversed by array_inverse and then foreach looped to create the overlapping effect... If that is the only feasible way to do it fine lol... was just wondering if there was a way to do it that was easier :)... Thanks for the reply :)
ShadowPuppet