Login   Register  
PHP Classes
elePHPant
Icontem

File: merge.pimg.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Tony Bogdanov  >  PIMG  >  merge.pimg.php  >  Download  
File: merge.pimg.php
Role: Class source
Content type: text/plain
Description: Merging two images
Class: PIMG
Process images using multiple operations
Author: By
Last change: 1.1
Date: 2010-10-31 18:38
Size: 1,343 bytes
 

Contents

Class file image Download
<?php
/* PIMG module: merges two pimg images with a define xy offset */
class pimg_merge
{
    
/* Resources */
    
private $pimg;
    
    
// PIMG constructor
    
function __construct($pimg)
    {
        
$this -> pimg $pimg;
    }
    
    
    
    
/*
        Merges the given pimg image over the original pimg image with the given xy offset
        @param: $copy - the pimg image to merge on top
        @param: $x - x offset (signed)
        @param: $y - y offset (signed)
        @result: a pointer to the caller pimg class for furthur usage
    */
    
function init($copy$x 0$y 0$pct 100)
    {
        
/* INPUT VALIDATORS */
        
if (!$copy instanceOf pimg_image)
            
$this -> pimg -> setDebug('The passed merge image is not a valid pimg_image resource''error'__CLASS__);
        
        
// Check if the $copy is actually the original pimg
        
if ($this -> pimg == $copy)
            
$copyImg $this -> pimg -> newImage($copy -> renderString());
        else
            
$copyImg $copy -> handle();
        
        
// Layer over the image
        
if ($pct == 100)
            
imagecopyresampled($this -> pimg -> handle(), $copyImg$x$y00$copy -> width(), $copy -> height(), $copy -> width(), $copy -> height());
        elseif (
$pct)
            
imagecopymerge($this -> pimg -> handle(), $copyImg$x$y00imagesx($copyImg), imagesy($copyImg), $pct);
        
        
// Return the caller pimg instance
        
return $this -> pimg;
    }
}
?>