Not sure if my last post was titled correctly to allow people to understand what I am looking for.

When using imagecopymerge you can put one image over another and if you set the source height to a pixel value that is half of the total source image height then only the top half of the image is shown and merged on top of the background image etc.

What I would like to do is reverse that and have the bottom of the image be shown, so if I have 2 images both 200px in height and I set pic 2 to merge over pic 1 with a source height of 100 it would only show the bottom 100px of pic 2 instead of the default where it shows the top 100px.

Is there an easy way to do this?

My current code is below.

PHP Code:
function imagecopymerge_alpha($dst_im$src_im$dst_x$dst_y$src_x$src_y$src_w$src_h$pct){
    if(!isset(
$pct)){
        return 
false;
    }
    
$pct /= 100;
    
// Get image width and height
    
$w imagesx$src_im );
    
$h imagesy$src_im );
    
// Turn alpha blending off
    
imagealphablending$src_imfalse );
    
// Find the most opaque pixel in the image (the one with the smallest alpha value)
    
$minalpha 127;
    for( 
$x 0$x $w$x++ )
    for( 
$y 0$y $h$y++ ){
        
$alpha = ( imagecolorat$src_im$x$y ) >> 24 ) & 0xFF;
        if( 
$alpha $minalpha ){
            
$minalpha $alpha;
        }
    }
    
//loop through image pixels and modify alpha for each
    
for( $x 0$x $w$x++ ){
        for( 
$y 0$y $h$y++ ){
            
//get current alpha value (represents the TANSPARENCY!)
            
$colorxy imagecolorat$src_im$x$y );
            
$alpha = ( $colorxy >> 24 ) & 0xFF;
            
//calculate new alpha
            
if( $minalpha !== 127 ){
                
$alpha 127 127 $pct * ( $alpha 127 ) / ( 127 $minalpha );
            } else {
                
$alpha += 127 $pct;
            }
            
//get the color index with new alpha
            
$alphacolorxy imagecolorallocatealpha$src_im, ( $colorxy >> 16 ) & 0xFF, ( $colorxy >> ) & 0xFF$colorxy 0xFF$alpha );
            
//set pixel with the new color + opacity
            
if( !imagesetpixel$src_im$x$y$alphacolorxy ) ){
                return 
false;
            }
        }
    }
    
// The image copy
    
imagecopy($dst_im$src_im$dst_x$dst_y$src_x$src_y$src_w$src_h);
}

$img_a imagecreatefrompng('images/dmbackground.png');
$img_b imagecreatefrompng('images/dmforeground.png');

imagecopymerge_alpha($img_a$img_b0000imagesx($img_b), (imagesy($img_b)/100)*65100);

header("Content-Type: image/png");
imagesavealpha($img_atrue);
imagepng($img_aNULL); 
And it calculates a percentage of the image height of the overlaying image ($img_b) so it only displays that percentage, currently it does this from top to bottom but I need bottom to top, is this possible? I tried using negative numbers and that shows nothing at all.

Any advice?

Thanks