sWo0p
April 24, 2006, 7:27pm
1
was working on a image uploadscript with resize and watermark section… script already works fine but i run a snag… my watermark section does’nt seem to work…
mybe you guys can find de problem:
<?
//* Lees naam afbeelding uit url en koppel VIEW tag aan template *//
if ($_GET['afbeelding']){
$path_watermerk = $wtrm_dir . "/water_sWo0p.png";
//* watermerk test echo "<img src=\"" . $path_watermerk . "\">";
$watermerk = imagecreatefrompng($path_watermerk);
$watermerk_width = imagesx($watermerk);
$watermerk_height = imagesy($watermerk);
$image = imagecreatefromjpeg($upl_dir . "\\" . $_GET['afbeelding']);
$size = getimagesize($upl_dir . $_GET['afbeelding']);
$xas = $size[0] - $watermerk_width - 5;
$yas = 5;
imagecopymerge($image, $watermerk, $xas, $yas, 0, 0, $watermerk_width, $watermerk_height, 100);
}
else
echo "Geen naam meegegeven in URL.";
header('content-type: image/jpeg');
$afb = imagejpeg($image); //imagejpeg($image);
$afbeelding = '<img src=" '.$afb.' " width="400" border="1" />';
$tpl->assign("VIEW_IMAGE", "$afbeelding");
?>
there is a template system in my script but you guys can work around that… :thumb2:
teiz77
April 25, 2006, 7:25am
2
<?
//* Lees naam afbeelding uit url en koppel VIEW tag aan template *//
if ($_GET['afbeelding']){
$path_watermerk = $wtrm_dir . "/water_sWo0p.png";
//* watermerk test echo "<img src=\"" . $path_watermerk . "\">";
$watermerk = imagecreatefrompng($path_watermerk);
$watermerk_width = imagesx($watermerk);
$watermerk_height = imagesy($watermerk);
$image = imagecreatefromjpeg($upl_dir . "/" . $_GET['afbeelding']);
$size = getimagesize($upl_dir. "/" . $_GET['afbeelding']);
$xas = $size[0] - $watermerk_width - 5;
$yas = 5;
imagecopy($image, $watermerk,$xas, $yas,0,0,$watermerk_width,$watermerk_height);
}
else
echo "Geen naam meegegeven in URL.";
header('content-type: image/jpeg');
$afb = imagejpeg($image); //imagejpeg($image);
$afbeelding = '<img src=" '.$afb.' " width="400" border="1" />';
$tpl->assign("VIEW_IMAGE", "$afbeelding");
?>
Try this… imagecopymerge doesn’t seem to support alpha channels. I also changed some slashes, otherwise the script couldn’t find the files.
sWo0p
April 25, 2006, 9:21pm
3
i did’nt have the time to try it out yet, but knowing you it’ll work, thanks dude… but axplain what was wrong in my script… ?
Ankou
April 26, 2006, 12:47am
4
According to teiz77 the following things were wrong (or not working):
The imagecopymerge thing is pretty clear. If you need more info, look at the PHP manual on that. It usually does a good job of explaining possible issues (especially in the comments).
The slashes. Well you were using “\” when it should have been “/” for the path to the images. And there was one case where you didn’t have the “/” to separate the path from the file name:
The “\” vs. “/” problem:
$image = imagecreatefromjpeg($upl_dir . "\\" . $_GET['afbeelding']);
The missing “/” - you needed this b/n $upl_dir and $_GET :
$size = getimagesize($upl_dir . $_GET['afbeelding']);
(PHP code above is your code, the correction can be seen in teiz77’s code)
BTW - teiz77, I didn’t mean to jump in on your post here and “take over” but I figured I’d explain it incase sWo0p came back for an answer before you could reply. I hope that was okay (and I hope I didn’t miss anything).
teiz77
April 26, 2006, 7:08am
5
Ankou:
According to teiz77 the following things were wrong (or not working):
The imagecopymerge thing is pretty clear. If you need more info, look at the PHP manual on that. It usually does a good job of explaining possible issues (especially in the comments).
The slashes. Well you were using “\” when it should have been “/” for the path to the images. And there was one case where you didn’t have the “/” to separate the path from the file name:
The “\” vs. “/” problem:
$image = imagecreatefromjpeg($upl_dir . "\\" . $_GET['afbeelding']);
The missing “/” - you needed this b/n $upl_dir and $_GET :
$size = getimagesize($upl_dir . $_GET['afbeelding']);
(PHP code above is your code, the correction can be seen in teiz77’s code)
BTW - teiz77, I didn’t mean to jump in on your post here and “take over” but I figured I’d explain it incase sWo0p came back for an answer before you could reply. I hope that was okay (and I hope I didn’t miss anything).
I couldn’t have said it better :thumb: