Location: PHPKode > scripts > Print Logo On Image > print-logo-on-image/print_logo.inc.php
<?php
// This class print .png logo on jpg image | by s.mustafa | hide@address.com

class PrintLogo {
	var $img_logo = '';
	var $img_pic = '';
	
	var $dpx = 5;
	var $dpy = 5;

	function createImageAndLogo($pic_file, $logo_file) {
		$this->img_pic = imagecreatefromjpeg($pic_file);
		$this->img_logo = imagecreatefrompng($logo_file);
	}

	// note: $align | 1 = top left, 2 = top right, 3 = bottom right, 4 = bottom left, 5 = bottom center, 6 = top center

	function setAlign($align) {
		if ($align ==1) {
			$this->dpy = 5;
			$this->dpx = 5;
		} elseif ($align ==2) {
			$this->dpy = 5;
			$this->dpx = imagesx($this->img_pic)-(imagesx($this->img_logo)+5);
		} elseif ($align ==3) {
			$this->dpy = imagesy($this->img_pic)-(imagesy($this->img_logo)+5);
			$this->dpx = imagesx($this->img_pic)-(imagesx($this->img_logo)+5);
		} elseif ($align ==4) {
			$this->dpy = imagesy($this->img_pic)-(imagesy($this->img_logo)+5);
			$this->dpx = 5;
		} elseif ($align ==5) {
			$this->dpy = imagesy($this->img_pic)-(imagesy($this->img_logo)+5);
			$dc = imagesx($this->img_pic)/2;
			$dc2 = imagesx($this->img_logo)/2;
			$this->dpx = $dc-$dc2;
		} elseif ($align ==6) {
			$this->dpy = 5;
			$dc = imagesx($this->img_pic)/2;
			$dc2 = imagesx($this->img_logo)/2;
			$this->dpx = $dc-$dc2;
		} else {
			$this->dpy = 5;
			$this->dpx = 5;
		}

	}

	function InsertLogo($align) {
		$this->setAlign($align);
		$sx = imagesx($this->img_logo);
		$sy = imagesy($this->img_logo);

		imagecopy($this->img_pic, $this->img_logo, $this->dpx, $this->dpy, 0, 0, $sx, $sy);
	}

	function showImage() {
		imagejpeg($this->img_pic, 'finshed_image.jpg');
		echo '<img src="finshed_image.jpg" />';
	}
}
Return current item: Print Logo On Image