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
水印不申请先生..! –