22. august 2005 - 16:39
Der er
3 kommentarer og
1 løsning
function med watermark skal have resize med
function watermark($srcfilename, $newname, $watermark, $quality)
{
global $path_to_save_with_watermark;
$imageInfo = getimagesize($srcfilename);
$width = $imageInfo[0];
$height = $imageInfo[1];
$logoinfo = getimagesize($watermark);
$logowidth = $logoinfo[0];
$logoheight = $logoinfo[1];
$horizextra =$width - $logowidth;
$vertextra =$height - $logoheight;
$horizmargin = round($horizextra / 2);
$vertmargin = round($vertextra / 1);
$photoImage = ImageCreateFromJPEG($srcfilename);
ImageAlphaBlending($photoImage, true);
$logoImage = ImageCreateFromPNG($watermark);
$logoW = ImageSX($logoImage);
$logoH = ImageSY($logoImage);
ImageCopy($photoImage, $logoImage, $horizmargin, $vertmargin, 0, 0, $logoW, $logoH);
//ImageJPEG($photoImage); // output to browser
ImageJPEG($photoImage, $path_to_save_with_watermark . $newname, $quality);
ImageDestroy($photoImage);
ImageDestroy($logoImage);
}
Hej med jer, billederne må max være 650 i bredden.
Håber i kan hjælpe :o)
22. august 2005 - 22:04
#1
Se om dette ikke virker:
function watermark($srcfilename, $newname, $watermark, $quality)
{
global $path_to_save_with_watermark;
$imageInfo = getimagesize($srcfilename);
$width = $imageInfo[0];
$height = $imageInfo[1];
$logoinfo = getimagesize($watermark);
$logowidth = $logoinfo[0];
$logoheight = $logoinfo[1];
$horizextra =$width - $logowidth;
$vertextra =$height - $logoheight;
$horizmargin = round($horizextra / 2);
$vertmargin = round($vertextra / 1);
$photoImage = ImageCreateFromJPEG($srcfilename);
ImageAlphaBlending($photoImage, true);
$logoImage = ImageCreateFromPNG($watermark);
$logoW = ImageSX($logoImage);
$logoH = ImageSY($logoImage);
ImageCopy($photoImage, $logoImage, $horizmargin, $vertmargin, 0, 0, $logoW, $logoH);
//ImageJPEG($photoImage); // output to browser
$scale = 650 / $width;
$nw = round( $width * $scale, 0 );
$nh = round( $height * $scale, 0 );
$dstim = imagecreatetruecolor( $nw, $nh );
imagecopyresampled( $dstim, $photoImage, 0, 0, 0, 0, $nw, $nh, $width, $height );
ImageJPEG($dstim, $path_to_save_with_watermark . $newname, $quality);
ImageDestroy($photoImage);
ImageDestroy($logoImage);
}