Parašė Donatis07· 2008 Vas. 1 16:02:23
#2
cia kai prasai, tai niekas nereaguoja?
cia yra gfx.php failas, kuriame ir kuriamas watermarkas
<?php
function WatermarkImage($Photo_id, $WatermarkImage, $WhatImage, $Transparancy=10, $Quality=75)
{
//Safe mode or not
define("SAFEMODE", @ini_get("safe_mode") ? true : false);
//Get the maincore settings
include_once("pagr_kodas.php");
//Search for image properties
$result = dbquery(
"SELECT tp.*, ta.* FROM ".$db_prefix."photos tp
LEFT JOIN ".$db_prefix."photo_albums ta USING (album_id)
WHERE photo_id='$Photo_id' OR photo_thumb1='$Photo_id' OR photo_thumb2='$Photo_id' GROUP BY tp.photo_id
");
$data = dbarray($result);
$photo_types = array(".gif",".jpg",".jpeg",".png");
//Get image thumb/full image or resized image extension and source
if ($WhatImage == "thumb")
{
$photo_ext = strtolower(strrchr(PHOTOS.(!SAFEMODE ? "album_".$data['album_id']."/" : "").$data['photo_thumb1'],"."));
$source_photo = PHOTOS.(!SAFEMODE ? "album_".$data['album_id']."/" : "").$data['photo_thumb1'];
}
elseif ($WhatImage == "img")
{
$photo_ext = strtolower(strrchr(PHOTOS.(!SAFEMODE ? "album_".$data['album_id']."/" : "").$data['photo_filename'],"."));
$source_photo = PHOTOS.(!SAFEMODE ? "album_".$data['album_id']."/" : "").$data['photo_filename'];
}
elseif ($WhatImage == "res")
{
$photo_ext = strtolower(strrchr(PHOTOS.(!SAFEMODE ? "album_".$data['album_id']."/" : "").$data['photo_thumb2'],"."));
$source_photo = PHOTOS.(!SAFEMODE ? "album_".$data['album_id']."/" : "").$data['photo_thumb2'];
} else { exit; }
//Check if the file is an image file...
//Then create image
if (in_array($photo_ext, $photo_types))
{
if ($photo_ext == ".gif")
{
header("Content-Type: image/gif");
$photo = imagecreatefromgif($source_photo);
} elseif ($photo_ext == ".jpg" OR $photo_ext == ".jpeg") {
header("Content-Type: image/jpeg");
$photo = imagecreatefromjpeg($source_photo);
} elseif ($photo_ext == ".png") {
header("Content-Type: image/png");
$photo = imagecreatefrompng($source_photo);
} else {
return "File extension not valid";
exit;
}
} else {
return "File type not valid";
exit;
}
//Watermark
$logo = PHOTOS.$WatermarkImage;
$watermark = imagecreatefrompng($logo);
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
// This is optional. Use it to make a specific color in the watermark transparent. If you want to use it; remove the comments, and choose a color ($black, $white etc)
// setup transparent color (pick one):
// $black = imagecolorallocate($watermark, 0x00, 0x00, 0x00);
$white = imagecolorallocate($watermark, 0xFF, 0xFF, 0xFF);
// $magenta = imagecolorallocate($watermark, 0xFF, 0x00, 0xFF);
// $red = ImageColorAllocate($watermark, 255, 0, 0);
// $green = ImageColorAllocate($watermark, 21, 107, 43);
// $yellow = ImageColorAllocate($watermark, 255, 255, 0);
// $blue = ImageColorAllocate($watermark, 0, 51, 255);
// and use it:
// imagecolortransparent($watermark, $white);
//location of the watermark on the source image
$size = getimagesize($source_photo);
$dest_x = ($size[0] - $watermark_width) - 5;
$dest_y = ($size[1] - $watermark_height) - 5;
//make the image (merge source image with watermark)
imagecopymerge($photo, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $Transparancy);
//output the image
imagejpeg($photo, '', $Quality);
//free memory
imagedestroy($photo);
imagedestroy($watermark);
}
//Get the id's
$img_id = $_GET['img_id'];
$thumb_id = $_GET['thumb_id'];
$res_id = $_GET['res_id'];
//
//Full size image Watermark integration....
//
if (isset($img_id)) {
WatermarkImage($img_id, "watermarklarge.png", "img", 80, 100);
}
//
//Thumbnail Watermark integration....
//
elseif (isset($thumb_id)) {
WatermarkImage($thumb_id, "watermarksmall.png", "thumb", 80, 100);
}
//
//Resized image Watermark integration....
//
elseif (isset($res_id)) {
WatermarkImage($res_id, "watermarknormal.png", "res", 50, 80);
} else {echo "Error";}
?>
kurioj vietoj ir ka padaryti, kad jis butu be fono ir nuotraukos viduryje, o ne kampe?