Code: Select all
<?php
$podaci = GetImageSize($_GET["mapa"] . $_GET["foto"]);
$foto_u_stazi = $_GET["mapa"] . $_GET["foto"];
$mapa3 = $_GET["mapa"];
$mapa4 = strstr($mapa3, "orginal");
$percent = 0.45;
/*if($mapa4 == "orginal/") { $water_u_stazi = "../img/057watermark.png"; } else
{ $water_u_stazi = "../img/057watermark2.png"; }
*/
$water_u_stazi = "watermark.png";
$height = $podaci[1];
$width = $podaci[0];
if($podaci["mime"] == "image/jpeg") {
//header("Content-type: image/jpeg");
$podloga = imagecreatefromjpeg ($foto_u_stazi);
}
$color = imagecolorallocate($podloga, 255, 255, 255);
$color2 = imagecolorallocate($podloga, 0, 0, 0);
$watermark = imagecreatefrompng($water_u_stazi);
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
imagecolortransparent($watermark, $color2);
//$image = imagecreatetruecolor($watermark_width, $watermark_height);
if($_GET["type"] == "1") {
$dest_x = $width - $watermark_width - 10;
$dest_y = $height - $watermark_height - 10;
imagecopymerge($podloga, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 67);
} else {
$newwidth = $watermark_width * $percent;
$newheight = $watermark_height * $percent;
$new_water = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($new_water, $watermark, 0, 0, 0, 0, $newwidth, $newheight, $watermark_width, $watermark_height);
$color3 = imagecolorat ($new_water , 0, 0);
imagecolortransparent($new_water, $color3);
$dest_x = $width - $newwidth - (10);
$dest_y = $height - $newheight - (10);
imagecopymerge($podloga, $new_water, $dest_x, $dest_y, 0, 0, $newwidth, $newheight, 70);
}
header("Content-type: image/png");
imagepng($podloga);
//===============================================================
?>however, because of this 'foto' twice at the top, i'm unable to, for example, put watermark on other image than in folder site.com/foto.
what i'd like to do is be able to give watermak image on whatever jpg file on my server i want.. so it should look like http://www.site.com/foto.php?foto=image ... er/&type=2
that's basically it.
can someone try to help me fixing my current working code? thanks!