Parašė weberiz· 2010 Sau. 18 16:01:54
#9
aik tu moket už toki dalyka...
turiu koda bet kaškas jame netaip nes neveik
.htaccess
RewriteEngine On
RewriteRule ^(.+)\.jpg$ wrapper.php?image=$1\.jpg [L]
RewriteRule ^(.+)\.gif$ wrapper.php?image=$1\.gif [L]
RewriteRule ^(.+)\.png$ wrapper.php?image=$1\.png [L]
RewriteRule ^(.+)\.bmp$ wrapper.php?image=$1\.bmp [L]
wrapper.php
<?php
$watermark = “watermark.png”;
$image = $_GET["image"];
if (empty($image)) die();
if (!file_exists($image)) {
header(“404 Not Found”);
echo “File Not Found.”; die();
}
$outputType = getFileType($image);
watermark($image, $watermark, $outputType);
/**
Outputs the image $source with $watermark in the lower right corner.
@param $source the source image
@param $watermark the watermark to apply
@param $outputType the type to output as (png, jpg, gif, etc.)
defaults to the image type of $source if left blank
*/
function watermark($source, $watermark, $outputType=”") {
$sourceType = getFileType($source);
$watermarkType = getFileType($watermark);
if (empty($outputType)) $outputType = $sourceType;
if ($outputType == “gif”) $outputType = “png”;
header(“Content-type:image/$outputType”);
$createSource = “ImageCreateFrom”.strtoupper($sourceType);
$showImage = “Image”.strtoupper($outputType);
$createWatermark = “ImageCreateFrom”.strtoupper($watermarkType);
// Load original and watermark to memory
$output = $createSource($source);
$logo = $createWatermark($watermark);
ImageAlphaBlending($output, true);
// Find proper coordinates so watermark will be in the lower right corner
$x = ImageSX($output) – ImageSX($logo);
$y = ImageSY($output) – ImageSY($logo);
// Display
ImageCopy($output, $logo, $x, $y, 0, 0, ImageSX($logo), ImageSY($logo));
$showImage($output);
// Purge
ImageDestroy($output);
ImageDestroy($logo);
}
function getFileType($string) {
$type = strtolower(eregi_replace(“^(.*)\.”,”",$string));
if ($type == “jpg”) $type = “jpeg”;
return $type;
}
Redagavo weberiz· 2010 Sau. 18 16:01:20