File: /home/panama/public_html_old/display_image.php
<?
include("image_class.php");
$filename = $_GET['path'];
$__logo = $_GET['logo'];
$_wLogo = $_GET['w'];
$_hLogo = $_GET['h'];
$_xLogo = $_GET['x'];
$_yLogo = $_GET['y'];
$bgcolor = $_GET['bgcolor'];
if($_GET['watermark']!=-1)
//$MyStrig = "Laid on canvas";
$MyStrig = "";
$MyStringFontSize = 10;
//$MyStringX = 10;
//$MyStringY = 50;
if(file_exists($filename) and $_GET['width'] > 0 and $_GET['height'] > 0)
{
$im = new image();
$im->display_image($filename , $_GET['width'] , $_GET['height']);
$imageWidth = $im->required['width'];
//$imageHeight = $im->required['height'];
$height = $im->required['height'];
$aspectRatio = $imageWidth/$height;
$imageHeight = $im->required['width']/$aspectRatio;
$MyStringX = ($imageWidth/2)-60;
$MyStringY = ($imageHeight/2);
$imageMyStringColor = $im->rgb2hex2rgb("#330000");
$percent = 0.5;
$image = @getImageSize($filename);
$imageType=$image[2];
switch($imageType)
{
case '1':
// Content type
header('Content-type: image/gif');
// Resample
$imageFirst = imagecreatetruecolor($imageWidth, $imageHeight);
$image = imagecreatefromgif($filename);
@ imagealphablending($image, 1);
imagecopyresampled($imageFirst, $image, 0, 0, 0, 0, $imageWidth, $imageHeight, $im->image_property[0], $im->image_property[1]);
if(!file_exists($__logo))
{
imagestring($imageFirst, $MyStringFontSize, $MyStringX, $MyStringY, $MyStrig, $imageMyStringColor);
imagegif($imageFirst, null, 100);
}
break;
case '2':
// Content type
header('Content-type: image/jpeg');
// Resample
$imageFirst = imagecreatetruecolor($imageWidth, $imageHeight);
$image = imagecreatefromjpeg($filename);
@ imagealphablending($image, 1);
imagecopyresampled($imageFirst, $image, 0, 0, 0, 0, $imageWidth, $imageHeight, $im->image_property[0], $im->image_property[1]);
if(!file_exists($__logo))
{
imagestring($imageFirst, $MyStringFontSize, $MyStringX, $MyStringY, $MyStrig, $imageMyStringColor);
imagejpeg($imageFirst, null, 100);
}
break;
case '3':
// Content type
header('Content-type: image/png');
// Resample
$imageFirst = imagecreatetruecolor($imageWidth, $imageHeight);
$image = imagecreatefrompng($filename);
@ imagealphablending($image, 1);
imagecopyresampled($imageFirst, $image, 0, 0, 0, 0, $imageWidth, $imageHeight, $im->image_property[0], $im->image_property[1]);
if(!file_exists($__logo))
{
imagestring($imageFirst, $MyStringFontSize, $MyStringX, $MyStringY, $MyStrig, $imageMyStringColor);
imagepng($imageFirst, null, 100);
}
break;
}
$newImageWidth = $_GET['width'];
$newImageHeight = $_GET['height'];
echo $newImageWidth;
echo "<br>".$newImageHeight;
$arrayXY = $im->imageFillColorXY($newImageWidth,$image);
$newLogoWidth = $newImageWidth-($arrayXY["x"]*2);
$newLogoHeight = $newImageHeight -($arrayXY["y"]*2);
}
if(file_exists($__logo))
{
$_im = new image();
$_im->display_image($__logo , $_wLogo , $_hLogo);
$logoWidth = $newLogoWidth; //$_im->required['width'];
$logoHeight = $newLogoHeight; //$_im->required['height'];
$logoImage = @getImageSize($__logo);
$logoImageType=$logoImage[2];
// Resample
//this is for watermark
$cc= $_im->rgb2hex2rgb("#330000");
$logoX = (($_xLogo > 0)?$_xLogo:39);
$logoY = (($_yLogo > 0)?$_yLogo:38);
if(strlen(trim($bgcolor)) > 0)
{
// $imageWidth, $imageHeight
//331,242
$bgArray = array("x"=>18,"y"=>18,"w"=>$imageWidth-20,"h"=>$imageHeight-20);
$im->getBackground($imageFirst,"#".$bgcolor,$bgArray);
}
switch($logoImageType)
{
case '1':
header('Content-type: image/gif');
$imageLogo = imagecreatetruecolor($logoWidth, $logoHeight);
$logoImage = imagecreatefromgif($__logo);
imagecopyresampled($imageLogo, $logoImage, 0, 0, 0, 0, $logoWidth, $logoHeight, $_im->image_property[0], $_im->image_property[1]);
@ imagecopymerge($imageFirst, $imageLogo, $logoX,$logoY , 0, 0, $_wLogo, $_hLogo,100);
imagegif($imageFirst, null, 100);
break;
case '2':
header('Content-type: image/jpeg');
$imageLogo = imagecreatetruecolor($logoWidth, $logoHeight);
$logoImage = imagecreatefromjpeg($__logo);
imagecopyresampled($imageLogo, $logoImage, 0, 0, 0, 0, $logoWidth, $logoHeight, $_im->image_property[0], $_im->image_property[1]);
@ imagecopymerge($imageFirst, $imageLogo, $logoX,$logoY , 0, 0, $_wLogo, $_hLogo,100);
//this is for watermark
//imagestring($imageFirst, 10, 120, 130, $MyStrig, $cc);
imagejpeg($imageFirst, null, 100);
break;
case '3':
header('Content-type: image/png');
$imageLogo = imagecreatetruecolor($logoWidth, $logoHeight);
$logoImage = imagecreatefrompng($__logo);
imagecopyresampled($imageLogo, $logoImage, 0, 0, 0, 0, $logoWidth, $logoHeight, $_im->image_property[0], $_im->image_property[1]);
@ imagecopymerge($imageFirst, $imageLogo, $logoX,$logoY , 0, 0, $_wLogo, $_hLogo,100);
imagepng($imageFirst, null, 100);
break;
}
}
?>