0
我想爲用戶輸入添加水印圖像。它必須將處理後的圖像存儲在一個文件夾中。這裏是我用來上傳圖像並添加水印的代碼。作物和水印圖像在php
水印正在應用。但空的圖像存儲在服務器中。你能幫我做這個工作嗎?這裏是work I done till now
<?php
define('UPLOAD_DIR', 'images/');
$img = $_POST['image-data'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . uniqid() . '.png';
file_put_contents($file, $data);
$stamp = imagecreatefrompng('http://mygreetins.esy.es/new/images/watermark.png');
$im = imagecreatefrompng($file);
// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 0;
$marge_bottom = 0;
$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));
$file = UPLOAD_DIR . time() . '.png';
$success = file_put_contents($file, $im);
echo $file
?>
你能指定「究竟」是不是工作? – Mart
水印不申請先生..! –