【问题标题】:text watermark in php [closed]php中的文本水印[关闭]
【发布时间】:2015-02-28 08:35:46
【问题描述】:

我目前正在制作一个页面,您可以在其中上传图片。 我需要知道的是上传图片时添加的文本水印,您应该可以插入文本,该文本将显示在水印中。

这是我的 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>

我找了一会儿,没有找到我能正确理解的教程

【问题讨论】:

标签: php html watermark


【解决方案1】:

我会推荐你​​使用“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;

【讨论】:

    【解决方案2】:

    试试这个:

    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);
    

    【讨论】:

      猜你喜欢
      • 2018-05-30
      • 1970-01-01
      • 2010-11-22
      • 2011-01-15
      • 1970-01-01
      • 1970-01-01
      • 2010-09-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多