Просмотр файла script/markee.php

Размер файла: 3.02Kb
<?php
/*-----------------------------------------------------------------------------------------
mcGalleryPRO
All code is © 2003 Marc Cagninacci.
No files may be redistributed in whole or significant part.
----------------- mcgalleryPRO IS NOT FREE SOFTWARE -------------------
You should have receive a file called license.txt in this package
--------------------------------------------------------------------------------------------*/
include 'admin/conf.inc.php';

$srcfilename = $im;
$imageInfo = getimagesize($srcfilename);
$width = $imageInfo[0];
$height = $imageInfo[1];

if ($wm == 2) { unset($watermark_string); unset($watermark_logo); }
elseif ($wm == 1) $watermark_string = stripslashes($watermark_string);
else $watermark_string = urldecode(stripslashes($wm));

	if ($imageInfo[2] == '2')	$ft = 'jpg';
	else										$ft = 'png';
header ('Content-type: image/'.$tf);

	if ($ft == 'jpg')	$photoImage = ImageCreateFromJPEG($srcfilename);
	else						$photoImage = ImageCreateFromPNG($srcfilename);

$fontwidth  = ImageFontWidth(5) * strlen($watermark_string);

if ($fontwidth < ($width + 25) && !empty($watermark_string))
{
$color1 = imagecolorallocate ($photoImage, 0, 0,0);
$color2 = imagecolorallocate ($photoImage, 255, 255,255);

	switch($string_align)
	{
		case 3:
			$text_x = $width - $fontwidth - 20;
			$text_y = $height - 30;
			break;
		case 2:
			$text_x = 20;
			$text_y = $height - 30;
			break;
		case 1:
			$text_x = $width - $fontwidth - 20;
			$text_y = 20;
			break;
		case 0:
			$text_x = 20;
			$text_y = 20;
			break;

	}

ImageString($photoImage, 5, $text_x - 3, $text_y - 1, $watermark_string, $color1);
ImageString($photoImage, 5, $text_x - 1, $text_y - 3, $watermark_string, $color1);
ImageString($photoImage, 5, $text_x - 3, $text_y - 3, $watermark_string, $color1);
ImageString($photoImage, 5, $text_x, $text_y, $string, $color1);
ImageString($photoImage, 5, $text_x - 1, $text_y - 1, $watermark_string, $color1);
ImageString($photoImage, 5, $text_x - 2, $text_y - 2, $watermark_string, $color2);
}


if (!empty($watermark_logo))
{
ImageAlphaBlending($photoImage, true);

$logoInfo = getimagesize('images/'.$watermark_logo);

$logoW = $logoInfo[0];
$logoH = $logoInfo[1];

	if ($logoW < $width / 2 && $logoH < $height / 2)
	{
 	if ($logoinfo[2] == 2)	$logoImage = ImageCreateFromJPEG('images/'.$watermark_logo);
 	else									$logoImage = ImageCreateFromPNG('images/'.$watermark_logo);

		switch($logo_align)
		{
			case '3':
				$logo_x = $width - $logoW - 20;
				$logo_y = $height - $logoH - 20;
				break;
			case '2':
				$logo_x = 20;
				$logo_y = $height - $logoH - 20;
				break;
			case '1':
				$logo_x = $width - $logoW - 20;
				$logo_y = 20;
				break;
			case '0':
				$logo_x = 20;
				$logo_y = 20;
				break;
		}
	ImageCopy($photoImage, $logoImage, $logo_x, $logo_y, 0, 0, $logoW, $logoH);
	}
}

	if ($ft == 'jpg')	ImageJPEG($photoImage);
	else						ImagePNG($photoImage);
ImageDestroy($photoImage);
ImageDestroy($logoImage);
?>