1
我想为图像加水印并保存。这里是我使用它的代码。这里是输出图像并将输出存储到文件中。我想保存它而不输出它。在php中的图像水印
// Load the stamp and the photo to apply the watermark to
$stamp = imagecreatefrompng('stamp.png');
$im = imagecreatefromjpeg('proverbs.jpeg');
// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);
// Copy the stamp image onto our photo using the margin offsets and the photo
// width to calculate positioning of the stamp.
imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));
// Output and free memory
header('Content-type: image/png');
ob_start();
// output jpeg (or any other chosen) format & quality
imagejpeg($im, NULL, 85);
// capture output to string
$contents = ob_get_contents();
// end capture
ob_end_clean();
//imagepng($im);
imagedestroy($im);
$fh = fopen("proverbs.jpeg", "w");
fwrite($fh, $contents);
fclose($fh);
万阿英,蒋达清是,其输出的“http://本地主机/ IM age/index.php“放到屏幕上。我不希望输出任何东西 – Andromeda 2009-10-20 11:14:40
已修复它...只是省略输出缓冲区 – Andromeda 2009-10-20 11:16:29
真棒!伟大的工作=) – mauris 2009-10-20 11:56:36