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