我目前正在制作一个页面,你可以在那里上传图片。我需要知道的是一个文本水印添加时,你上传的图像,你应该能够插入一个文本,这将显示在水印。
这是我的php
$location = '/usr/local/apache/htdocs/images/'.$_FILES['file']['name'];
if (is_uploaded_file($_FILES['file']['tmp_name'])) {
if (!move_uploaded_file($_FILES['file']['tmp_name'], $location)) {
echo 'you cant copy your file';
exit;
} else {
echo 'you uploaded correctly<br><br>';
exit;
}
exit;
}这就是html。
<input type="file" name="file" /><br />
<input type="submit" value="Send" /> <br/>
</form>我找了一段时间,但没有找到任何我可以正确理解的教程
发布于 2015-01-02 05:48:43
我建议你使用'Imagick‘扩展,通过它你可以使用下一步:
<?php
// Open the original image
$image = new Imagick();
$image->readImage("/path/to/image.jpg");
// Open the watermark
$watermark = new Imagick();
$watermark->readImage("/path/to/watermark.png");
// Overlay the watermark on the original image
$image->compositeImage($watermark, imagick::COMPOSITE_OVER, 0, 0);
// send the result to the browser
header("Content-Type: image/" . $image->getImageFormat());
echo $image;发布于 2015-01-02 09:16:24
试试这个:
php中的文本水印
$imagetobewatermark=imagecreatefrompng("images/muggu.png");
$font="../font/century gothic.ttf";
$fontsize="15";
$watermarktext="Muggu"; // text to be printed on image
$white = imagecolorallocate($imagetobewatermark, 255, 255, 255);
imagettftext($imagetobewatermark, $fontsize, 0, 20, 10, $white, $font, $watermarktext);
header("Content-type:image/png");
imagepng($imagetobewatermark);
imagedestroy($imagetobewatermark);https://stackoverflow.com/questions/27734929
复制相似问题