找到200个回复 (用户: 坏人)
  • 不现实
  • Etc可以用在高速以外的用途?
    390点击 / 2023-10-30发布 / 2023-11-04回复 / /
    黑色的就是,这个和代收一样,你要先有一定规模,然后可以和代收公司签约,然后读到ETC然后查询这个etc绑定的车牌是否有未付款的单,有就全部在ETC扣了。bb93efa953a7580407901714c8bb2821.jpeg(4.73 MB)
  • 测试工程费用
    3398点击 / 2023-03-29发布 / 2023-10-17回复 / /
    加入处理'无EXIF信息的图片'的方法
  • 测试工程费用
    3398点击 / 2023-03-29发布 / 2023-10-07回复 / /
    <!DOCTYPE html>
    <html>
    <head>
        <title>文件上传</title>
    </head>
    <body>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <h1>选择图片并自动上传到服务器</h1>
        <form enctype="multipart/form-data" action="/upload" method="post">
            <input type="file" accept="image/*" capture="camera" name="fileToUpload" id="fileToUpload">
            <select name="project" id="project">
                <option value="project1">项目1</option>
                <option value="project2">项目2</option>
                <option value="project3">项目3</option>
            </select>
            <input type="text" name="comments" id="comments" placeholder="备注">
            <input type="hidden" name="latitude" id="latitude" value="">
            <input type="hidden" name="longitude" id="longitude" value="">
        </form>

        <div id="response"></div>

        <script>
            document.querySelector('#fileToUpload').addEventListener('change', function () {
                var fileInput = document.querySelector('#fileToUpload');
                var file = fileInput.files[0];

                if (file) {
                    var formData = new FormData();
                    formData.append('fileToUpload', file);
                    formData.append('project', document.querySelector('#project').value);
                    formData.append('comments', document.querySelector('#comments').value);

                    // 获取用户的经纬度数据(假设通过某种方式获取到了)
                    var latitude = 123.456; // 用实际数据替换
                    var longitude = 78.910; // 用实际数据替换
                    formData.append('latitude', latitude);
                    formData.append('longitude', longitude);

                    var xhr = new XMLHttpRequest();
                    xhr.open('POST', '1.php', true);
                    xhr.onload = function () {
                        if (xhr.status === 200) {
                            // 服务器返回处理后的图像路径
                            var imagePath = xhr.responseText;
                            
                            // 更新页面以显示处理后的图像
                            var responseDiv = document.querySelector('#response');
                            responseDiv.innerHTML = '<h2>处理后的图像</h2><img src="' + imagePath + '" alt="处理后的图像" width="500">';
                        } else {
                            // 显示错误消息
                            var responseDiv = document.querySelector('#response');
                            responseDiv.textContent = '文件上传失败。';
                        }
                    };
                    xhr.send(formData);
                } else {
                    alert('请选择一个文件进行上传。');
                }
            });
        </script>
    </body>
    </html>用浏览器获取用户的经纬度数据,第一次打开网页就请求取得授权同意后才能使用
  • 测试工程费用
    3398点击 / 2023-03-29发布 / 2023-10-07回复 / /
    @坏人,计算X坐标你无计算
  • 测试工程费用
    3398点击 / 2023-03-29发布 / 2023-10-07回复 / /
    @坏人, 在处理的图片大小是711 × 400 px的时候字体行间隔不会相对缩小
  • 测试工程费用
    3398点击 / 2023-03-29发布 / 2023-10-06回复 / /
    @坏人,先把图片水印个代码全部先删了只保留文字水印写入的相关代码.<?php
    /*
    * author 张长伟
    * date   2009-3-27 16:30:12
    * 功能: PHP图片水印 (水印支持图片) 
    * 参数: 
    *      $groundImage   背景图片,即需要加水印的图片,暂只支持GIF,JPG,PNG格式; 
    *      $waterPos      水印位置,有10种状态,0为随机位置; 
    *                     1为顶端居左,2为顶端居中,3为顶端居右; 
    *                     4为中部居左,5为中部居中,6为中部居右; 
    *                     7为底端居左,8为底端居中,9为底端居右; 
    *      $waterImage    图片水印,即作为水印的图片,暂只支持GIF,JPG,PNG格式; 
    *      $waterText     文字水印,即把文字作为为水印,支持ASCII码,不支持中文; 
    *      $textFont      文字大小,值为1、2、3、4或5,默认为5; 
    *      $textColor     文字颜色,值为十六进制颜色值,默认为#FF0000(红色); 

    * 注意:
    *      Support GD 2.0,Support FreeType、GIF Read、GIF Create、JPG 、PNG 
    *      $waterImage 和 $waterText 最好不要同时使用,选其中之一即可,优先使用 $waterImage。 
    *      当$waterImage有效时,参数$waterString、$stringFont、$stringColor均不生效。 
    *      加水印后的图片的文件名和 $groundImage 一样。  
    */
    function imageWaterMark($groundImage, $waterPos = 9, $waterImage = "", $waterText =
        "", $textFont = 1, $textColor = "#FF0000")
    {
        $isWaterImage = false;
        $formatMsg = "暂不支持该文件格式,请用图片处理软件将图片转换为GIF、JPG、PNG格式。";
        //读取水印文件
        if (!empty($waterImage) && file_exists($waterImage)) {
            $isWaterImage = true;
            $water_info = getimagesize($waterImage);
            $water_w = $water_info[0]; //取得水印图片的宽
            $water_h = $water_info[1]; //取得水印图片的高
            switch ($water_info[2]) //取得水印图片的格式
                {
                case 1:
                    $water_im = imagecreatefromgif($waterImage);
                    break;
                case 2:
                    $water_im = imagecreatefromjpeg($waterImage);
                    break;
                case 3:
                    $water_im = imagecreatefrompng($waterImage);
                    break;
                default:
                    die($formatMsg);
            }
        }
        //读取背景图片
        if (!empty($groundImage) && file_exists($groundImage)) {
            $ground_info = getimagesize($groundImage);
            $ground_w = $ground_info[0]; //取得背景图片的宽
            $ground_h = $ground_info[1]; //取得背景图片的高
            switch ($ground_info[2]) //取得背景图片的格式
                {
                case 1:
                    $ground_im = imagecreatefromgif($groundImage);
                    break;
                case 2:
                    $ground_im = imagecreatefromjpeg($groundImage);
                    break;
                case 3:
                    $ground_im = imagecreatefrompng($groundImage);
                    break;
                default:
                    die($formatMsg);
            }
        } else {
            die("需要加水印的图片不存在!");
        }
        $water_w = 0; // 初始化水印宽度
        $water_h = 0; // 初始化水印高度
        //水印位置
        if ($isWaterImage) //图片水印
            {
            $water_w = $water_info[0];
            $water_h = $water_info[1];
            $w = $water_w;
            $h = $water_h;
            $label = "图片的";
        } else //文字水印
        {
            $temp = imagettfbbox(ceil($textFont * 3), 0, "ttff.ttf", $waterText); //取得使用 TrueType 字体的文本的范围
            $w = $temp[2] - $temp[6];
            $h = $temp[3] - $temp[7];
            unset($temp);
            $label = "文字区域";
        }
        //判断图片大小与水印大小
        //if( ($ground_w<$w) || ($ground_h<$h) )
        // {
        //  echo "需要加水印的图片的长度或宽度比水印".$label."还小,无法生成水印!";
        //  return;
        // }
        switch ($waterPos) {
            case 0: //随机
                $posX = rand(0, ($ground_w - $w));
                $posY = rand(0, ($ground_h - $h));
                break;
            case 1: //1为顶端居左
                $posX = 0;
                $posY = 0;
                break;
            case 2: //2为顶端居中
                $posX = ($ground_w - $w) / 2;
                $posY = 0;
                break;
            case 3: //3为顶端居右
                $posX = $ground_w - $w;
                $posY = 0;
                break;
            case 4: //4为中部居左
                $posX = 0;
                $posY = ($ground_h - $h) / 2;
                break;
            case 5: //5为中部居中
                $posX = ($ground_w - $w) / 2;
                $posY = ($ground_h - $h) / 2;
                break;
            case 6: //6为中部居右
                $posX = $ground_w - $w;
                $posY = ($ground_h - $h) / 2;
                break;
            case 7: //7为底端居左
                $posX = 0;
                $posY = $ground_h - $h;
                break;
            case 8: //8为底端居中
                $posX = ($ground_w - $w) / 2;
                $posY = $ground_h - $h;
                break;
            case 9: //9为底端居右
                $posX = $ground_w - $w;
                $posY = $ground_h - $h;
                break;
            default: //随机
                $posX = rand(0, ($ground_w - $w));
                $posY = rand(0, ($ground_h - $h));
                break;
        }
        //设定图像的混色模式
        imagealphablending($ground_im, true);
        // 解决变黑色问题(仅在有图片水印时执行)
        if ($isWaterImage) {
            //解决变黑色问题
            $resize_im = imagecreatetruecolor($water_w, $water_h);
            // 下面三行是重点,解决png、gif透明背景变黑色的问题
            imagesavealpha($ground_im, true);
            imagealphablending($resize_im, false); //不合并颜色,直接用$im图像颜色替换,包括透明色;
            imagesavealpha($resize_im, true); //不要丢了$resize_im图像的透明色;
        }
        if ($isWaterImage) //图片水印
            {
            imagecopy($ground_im, $water_im, $posX, $posY, 0, 0, $water_w, $water_h); //拷贝水印到目标文件
        } else //文字水印
        {
            if (!empty($textColor) && (strlen($textColor) == 7)) {
                $R = hexdec(substr($textColor, 1, 2));
                $G = hexdec(substr($textColor, 3, 2));
                $B = hexdec(substr($textColor, 5));
            } else {
                die("水印文字颜色格式不正确!");
            }
            imagestring($ground_im, $textFont, $posX, $posY, $waterText, imagecolorallocate
                ($ground_im, $R, $G, $B));

            // 将文字水印写入图像
            imagestring($ground_im, 20, 20, 50, "eeeeeeeeeeeeeeee", imagecolorallocate($ground_im,255, 0, 0));

        }
        //生成水印后的图片
        @unlink($groundImage);
        switch ($ground_info[2]) //取得背景图片的格式
            {
            case 1:
                imagegif($ground_im, $groundImage);
                break;
            case 2:
                imagejpeg($ground_im, $groundImage);
                break;
            case 3:
                imagepng($ground_im, $groundImage);
                break;
            default:
                die($errorMsg);
        }
        //释放内存
        if (isset($water_info))
            unset($water_info);
        if (isset($water_im))
            imagedestroy($water_im);
        unset($ground_info);
        imagedestroy($ground_im);
    }
    //---------------------------------------------------------------------------------------
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    // 在这之后执行您的代码
    $uploadfile = "images/651fa047ccf0c.jpg"; // 图片存放的路径
    $waterImage = ""; // 水印图片路径
    // 第一条文字水印
    $waterText = "Hello你的水印文本"; // 你的水印文本
    $asciiText = '';

    for ($i = 0; $i < strlen($waterText); $i++) {
        $asciiText .= ord($waterText[$i]) . ' ';
    }

    echo $asciiText;
    imageWaterMark($uploadfile, 5, $waterImage, $asciiText, "5",
        "#46FB04");
    echo "<img src=\"" . $uploadfile . "\" border=\"0\">";
    ?>
    <?php
    /**
     * // 创建一个背景图像
     * $width = 400;
     * $height = 200;
     * $image = imagecreatetruecolor($width, $height);

     * // 定义颜色
     * $bgColor = imagecolorallocate($image, 255, 255, 255); // 背景颜色为白色
     * $textColor = imagecolorallocate($image, 255, 0, 0); // 文字颜色为红色

     * // 填充背景色
     * imagefill($image, 0, 0, $bgColor);

     * // 文字水印内容
     * $watermarkText = "Watermark";

     * // 字体文件路径
     * $fontFile = "ttff.ttf"; // 请确保此文件存在于脚本所在目录或指定路径中

     * // 字体大小
     * $fontSize = 20;

     * // 水印位置
     * $watermarkX = 20;
     * $watermarkY = 50;

     * // 将文字水印写入图像
     * imagestring($image, 20, 20, 50, "eeeeeeeeeeeeeeee", imagecolorallocate($image, 255, 0, 0));
    imagestring($image, $fontSize, $watermarkX, $watermarkY, $watermarkText, $textColor);

     * // 输出图像
     * header("Content-type: image/png");
     * imagepng($image);

     * // 释放图像资源
     * imagedestroy($image);
     */
    ?>
  • 测试工程费用
    3398点击 / 2023-03-29发布 / 2023-10-06回复 / /
    函数中字体文件路径是 "ttff.ttf"是正确的已经试过可以用
  • 测试工程费用
    3398点击 / 2023-03-29发布 / 2023-10-06回复 / /
    <?php
    /*
    * author 张长伟
    * date   2009-3-27 16:30:12
    * 功能: PHP图片水印 (水印支持图片) 
    * 参数: 
    *      $groundImage   背景图片,即需要加水印的图片,暂只支持GIF,JPG,PNG格式; 
    *      $waterPos      水印位置,有10种状态,0为随机位置; 
    *                     1为顶端居左,2为顶端居中,3为顶端居右; 
    *                     4为中部居左,5为中部居中,6为中部居右; 
    *                     7为底端居左,8为底端居中,9为底端居右; 
    *      $waterImage    图片水印,即作为水印的图片,暂只支持GIF,JPG,PNG格式; 
    *      $waterText     文字水印,即把文字作为为水印,支持ASCII码,不支持中文; 
    *      $textFont      文字大小,值为1、2、3、4或5,默认为5; 
    *      $textColor     文字颜色,值为十六进制颜色值,默认为#FF0000(红色); 

    * 注意:
    *      Support GD 2.0,Support FreeType、GIF Read、GIF Create、JPG 、PNG 
    *      $waterImage 和 $waterText 最好不要同时使用,选其中之一即可,优先使用 $waterImage。 
    *      当$waterImage有效时,参数$waterString、$stringFont、$stringColor均不生效。 
    *      加水印后的图片的文件名和 $groundImage 一样。  
    */
    function imageWaterMark($groundImage, $waterPos = 9, $waterImage = "", $waterText =
        "", $textFont = 1, $textColor = "#FF0000")
    {
        $isWaterImage = false;
        $formatMsg = "暂不支持该文件格式,请用图片处理软件将图片转换为GIF、JPG、PNG格式。";
        //读取水印文件
        if (!empty($waterImage) && file_exists($waterImage)) {
            $isWaterImage = true;
            $water_info = getimagesize($waterImage);
            $water_w = $water_info[0]; //取得水印图片的宽
            $water_h = $water_info[1]; //取得水印图片的高
            switch ($water_info[2]) //取得水印图片的格式
                {
                case 1:
                    $water_im = imagecreatefromgif($waterImage);
                    break;
                case 2:
                    $water_im = imagecreatefromjpeg($waterImage);
                    break;
                case 3:
                    $water_im = imagecreatefrompng($waterImage);
                    break;
                default:
                    die($formatMsg);
            }
        }
        //读取背景图片
        if (!empty($groundImage) && file_exists($groundImage)) {
            $ground_info = getimagesize($groundImage);
            $ground_w = $ground_info[0]; //取得背景图片的宽
            $ground_h = $ground_info[1]; //取得背景图片的高
            switch ($ground_info[2]) //取得背景图片的格式
                {
                case 1:
                    $ground_im = imagecreatefromgif($groundImage);
                    break;
                case 2:
                    $ground_im = imagecreatefromjpeg($groundImage);
                    break;
                case 3:
                    $ground_im = imagecreatefrompng($groundImage);
                    break;
                default:
                    die($formatMsg);
            }
        } else {
            die("需要加水印的图片不存在!");
        }
        //水印位置
        if ($isWaterImage) //图片水印
            {
            $w = $water_w;
            $h = $water_h;
            $label = "图片的";
        } else //文字水印
        {
            $temp = imagettfbbox(ceil($textFont * 3), 0, "ttff.ttf", $waterText); //取得使用 TrueType 字体的文本的范围
            $w = $temp[2] - $temp[6];
            $h = $temp[3] - $temp[7];
            unset($temp);
            $label = "文字区域";
        }
        //判断图片大小与水印大小
        //if( ($ground_w<$w) || ($ground_h<$h) )
        // {
        //  echo "需要加水印的图片的长度或宽度比水印".$label."还小,无法生成水印!";
        //  return;
        // }
        switch ($waterPos) {
            case 0: //随机
                $posX = rand(0, ($ground_w - $w));
                $posY = rand(0, ($ground_h - $h));
                break;
            case 1: //1为顶端居左
                $posX = 0;
                $posY = 0;
                break;
            case 2: //2为顶端居中
                $posX = ($ground_w - $w) / 2;
                $posY = 0;
                break;
            case 3: //3为顶端居右
                $posX = $ground_w - $w;
                $posY = 0;
                break;
            case 4: //4为中部居左
                $posX = 0;
                $posY = ($ground_h - $h) / 2;
                break;
            case 5: //5为中部居中
                $posX = ($ground_w - $w) / 2;
                $posY = ($ground_h - $h) / 2;
                break;
            case 6: //6为中部居右
                $posX = $ground_w - $w;
                $posY = ($ground_h - $h) / 2;
                break;
            case 7: //7为底端居左
                $posX = 0;
                $posY = $ground_h - $h;
                break;
            case 8: //8为底端居中
                $posX = ($ground_w - $w) / 2;
                $posY = $ground_h - $h;
                break;
            case 9: //9为底端居右
                $posX = $ground_w - $w;
                $posY = $ground_h - $h;
                break;
            default: //随机
                $posX = rand(0, ($ground_w - $w));
                $posY = rand(0, ($ground_h - $h));
                break;
        }
        //设定图像的混色模式
        imagealphablending($ground_im, true);
        //解决变黑色问题
        $resize_im = imagecreatetruecolor($water_w, $water_h);
        // 下面三行是重点,解决png、gif透明背景变黑色的问题
        imagesavealpha($ground_im, true);
        imagealphablending($resize_im, false); //不合并颜色,直接用$im图像颜色替换,包括透明色;
        imagesavealpha($resize_im, true); //不要丢了$resize_im图像的透明色;
        if ($isWaterImage) //图片水印
            {
            imagecopy($ground_im, $water_im, $posX, $posY, 0, 0, $water_w, $water_h); //拷贝水印到目标文件
        } else //文字水印
        {
            if (!empty($textColor) && (strlen($textColor) == 7)) {
                $R = hexdec(substr($textColor, 1, 2));
                $G = hexdec(substr($textColor, 3, 2));
                $B = hexdec(substr($textColor, 5));
            } else {
                die("水印文字颜色格式不正确!");
            }
            imagestring($ground_im, $textFont, $posX, $posY, $waterText, imagecolorallocate
                ($ground_im, $R, $G, $B));
        }
        //生成水印后的图片
        @unlink($groundImage);
        switch ($ground_info[2]) //取得背景图片的格式
            {
            case 1:
                imagegif($ground_im, $groundImage);
                break;
            case 2:
                imagejpeg($ground_im, $groundImage);
                break;
            case 3:
                imagepng($ground_im, $groundImage);
                break;
            default:
                die($errorMsg);
        }
        //释放内存
        if (isset($water_info))
            unset($water_info);
        if (isset($water_im))
            imagedestroy($water_im);
        unset($ground_info);
        imagedestroy($ground_im);
    }
    //---------------------------------------------------------------------------------------
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    // 在这之后执行您的代码
    $uploadfile = "images/651fa047ccf0c.jpg"; // 图片存放的路径
    $waterImage = ""; // 水印图片路径
    // 第一条文字水印
    imageWaterMark($uploadfile, 9, $waterImage, "水印1", 3, "#FF0000");
    echo "<img src=\"" . $uploadfile . "\" border=\"0\">";
    ?>可是错误还在
    Notice: Undefined variable: water_w in /www/wwwroot/88.162118.cn/1.php on line 140

    Notice: Undefined variable: water_h in /www/wwwroot/88.162118.cn/1.php on line 140
  • 测试工程费用
    3398点击 / 2023-03-29发布 / 2023-10-06回复 / /
    @坏人,<?php
    /**
    * author 张长伟
    * date   2009-3-27 16:30:12
    * 功能: PHP图片水印 (水印支持图片) 
    * 参数: 
    *      $groundImage   背景图片,即需要加水印的图片,暂只支持GIF,JPG,PNG格式; 
    *      $waterPos      水印位置,有10种状态,0为随机位置; 
    *                     1为顶端居左,2为顶端居中,3为顶端居右; 
    *                     4为中部居左,5为中部居中,6为中部居右; 
    *                     7为底端居左,8为底端居中,9为底端居右; 
    *      $waterImage    图片水印,即作为水印的图片,暂只支持GIF,JPG,PNG格式; 
    *      $waterText     文字水印,即把文字作为为水印,支持ASCII码,不支持中文; 
    *      $textFont      文字大小,值为1、2、3、4或5,默认为5; 
    *      $textColor     文字颜色,值为十六进制颜色值,默认为#FF0000(红色); 

    * 注意:
    *      Support GD 2.0,Support FreeType、GIF Read、GIF Create、JPG 、PNG 
    *      $waterImage 和 $waterText 最好不要同时使用,选其中之一即可,优先使用 $waterImage。 
    *      当$waterImage有效时,参数$waterString、$stringFont、$stringColor均不生效。 
    *      加水印后的图片的文件名和 $groundImage 一样。  
    */
    function imageWaterMarkWithTexts($groundImage, $waterPos = 9, $waterImage = "", $waterTexts = [])
    {
        $isWaterImage = false;
        $formatMsg = "暂不支持该文件格式,请用图片处理软件将图片转换为GIF、JPG、PNG格式。";
        //读取水印文件
        if (!empty($waterImage) && file_exists($waterImage)) {
            $isWaterImage = true;
            $water_info = getimagesize($waterImage);
            $water_w = $water_info[0]; //取得水印图片的宽
            $water_h = $water_info[1]; //取得水印图片的高

            switch ($water_info[2]) //取得水印图片的格式
                {
                case 1:
                    $water_im = imagecreatefromgif($waterImage);
                    break;
                case 2:
                    $water_im = imagecreatefromjpeg($waterImage);
                    break;
                case 3:
                    $water_im = imagecreatefrompng($waterImage);
                    break;
                default:
                    die($formatMsg);
            }
        }

        //读取背景图片
        if (!empty($groundImage) && file_exists($groundImage)) {
            $ground_info = getimagesize($groundImage);
            $ground_w = $ground_info[0]; //取得背景图片的宽
            $ground_h = $ground_info[1]; //取得背景图片的高

            switch ($ground_info[2]) //取得背景图片的格式
                {
                case 1:
                    $ground_im = imagecreatefromgif($groundImage);
                    break;
                case 2:
                    $ground_im = imagecreatefromjpeg($groundImage);
                    break;
                case 3:
                    $ground_im = imagecreatefrompng($groundImage);
                    break;
                default:
                    die($formatMsg);
            }
        } else {
            die("需要加水印的图片不存在!");
        }

        //水印位置
        if ($isWaterImage) //图片水印
            {
            $w = $water_w;
            $h = $water_h;
            $label = "图片的";
        } else //文字水印
        {
            $temp = imagettfbbox(ceil($textFont * 3), 0, "ttff.ttf", $waterText); //取得使用 TrueType 字体的文本的范围
            $w = $temp[2] - $temp[6];
            $h = $temp[3] - $temp[7];
            unset($temp);
            $label = "文字区域";
        }
        //判断图片大小与水印大小
        //if( ($ground_w<$w) || ($ground_h<$h) )
        // {
        //  echo "需要加水印的图片的长度或宽度比水印".$label."还小,无法生成水印!";
        //  return;
        // }
        switch ($waterPos) {
            case 0: //随机
                $posX = rand(0, ($ground_w - $w));
                $posY = rand(0, ($ground_h - $h));
                break;
            case 1: //1为顶端居左
                $posX = 0;
                $posY = 0;
                break;
            case 2: //2为顶端居中
                $posX = ($ground_w - $w) / 2;
                $posY = 0;
                break;
            case 3: //3为顶端居右
                $posX = $ground_w - $w;
                $posY = 0;
                break;
            case 4: //4为中部居左
                $posX = 0;
                $posY = ($ground_h - $h) / 2;
                break;
            case 5: //5为中部居中
                $posX = ($ground_w - $w) / 2;
                $posY = ($ground_h - $h) / 2;
                break;
            case 6: //6为中部居右
                $posX = $ground_w - $w;
                $posY = ($ground_h - $h) / 2;
                break;
            case 7: //7为底端居左
                $posX = 0;
                $posY = $ground_h - $h;
                break;
            case 8: //8为底端居中
                $posX = ($ground_w - $w) / 2;
                $posY = $ground_h - $h;
                break;
            case 9: //9为底端居右
                $posX = $ground_w - $w;
                $posY = $ground_h - $h;
                break;
            default: //随机
                $posX = rand(0, ($ground_w - $w));
                $posY = rand(0, ($ground_h - $h));
                break;
        }

        //设定图像的混色模式
        imagealphablending($ground_im, true);
        //解决变黑色问题
        $resize_im = imagecreatetruecolor($water_w, $water_h);
        // 下面三行是重点,解决png、gif透明背景变黑色的问题
        imagesavealpha($ground_im, true);
        imagealphablending($resize_im, false); //不合并颜色,直接用$im图像颜色替换,包括透明色;
        imagesavealpha($resize_im, true); //不要丢了$resize_im图像的透明色;


        if ($isWaterImage) {
            imagecopy($ground_im, $water_im, $posX, $posY, 0, 0, $water_w, $water_h); //拷贝水印到目标文件
        } else {
            //遍历文本水印并将它们添加到图像
            foreach ($waterTexts as $waterTextInfo) {
                list($textX, $textY, $fontSize, $text, $textColor, $shadowColor) = $waterTextInfo;

                // 添加阴影效果
                $shadow = imagecolorallocate($ground_im, hexdec(substr($shadowColor, 1, 2)), hexdec(substr($shadowColor, 3, 2)), hexdec(substr($shadowColor, 5)));
                imagettftext($ground_im, $fontSize, 0, $textX + 2, $textY + 2, $shadow, "cour.ttf", $text);

                // 添加实际文本
                list($R, $G, $B) = sscanf($textColor, "#%02x%02x%02x");
                $textColorRGB = imagecolorallocate($ground_im, $R, $G, $B);
                imagettftext($ground_im, $fontSize, 0, $textX, $textY, $textColorRGB, "cour.ttf", $text);
            }
        }

        //生成水印后的图片
        @unlink($groundImage);
        switch ($ground_info[2]) {
            case 1:
                imagegif($ground_im, $groundImage);
                break;
            case 2:
                imagejpeg($ground_im, $groundImage);
                break;
            case 3:
                imagepng($ground_im, $groundImage);
                break;
            default:
                die($errorMsg);
        }

        //释放内存
        if (isset($water_info))
            unset($water_info);
        if (isset($water_im))
            imagedestroy($water_im);
        unset($ground_info);
        imagedestroy($ground_im);
    }
    //然后,您可以使用中文文字水印信息数组,如下所示:

    $uploadfile = "images/651f8316b3e95.jpg"; //图片存放的路径

    // 定义一个文本水印信息的数组,包含中文水印
    $waterTexts = [
        [10, 10, 5, "第一文字背景颜色天空蓝", "#FFFFFF", "#000000"], // X, Y, 字体大小, 文本, 文本颜色, 阴影颜色
        [10, 40, 3, date("Y-m-d H:i:s"), "#FFFFFF", "#000000"], // X, Y, 字体大小, 文本(系统时间), 文本颜色, 阴影颜色
        [10, 70, 3, "经纬度信息", "#FFFFFF", "#000000"], // X, Y, 字体大小, 文本(纬度/经度), 文本颜色, 阴影颜色
        [10, 100, 3, "位置名称", "#FFFFFF", "#000000"], // X, Y, 字体大小, 文本(位置名称), 文本颜色, 阴影颜色
        [10, 130, 3, "备注信息", "#FFFFFF", "#000000"], // X, Y, 字体大小, 文本(备注),文本颜色, 阴影颜色
        [10, 160, 3, "中文水印测试", "#FFFFFF", "#000000"], // 添加中文水印,X, Y, 字体大小, 中文文本, 文本颜色, 阴影颜色
    ];

    imageWaterMarkWithTexts($uploadfile, 9, "", $waterTexts);
    echo "<img src=\"" . $uploadfile . "\" border=\"0\">";

    ?>
    Warning: imagecreatetruecolor(): Invalid image dimensions in /www/wwwroot/88.162118.cn/waterImg.php on line 144

    Warning: imagealphablending() expects parameter 1 to be resource, boolean given in /www/wwwroot/88.162118.cn/waterImg.php on line 147

    Warning: imagesavealpha() expects parameter 1 to be resource, boolean given in /www/wwwroot/88.162118.cn/waterImg.php on line 148

    Warning: imagettftext(): Could not find/open font in /www/wwwroot/88.162118.cn/waterImg.php on line 160

    Warning: imagettftext(): Could not find/open font in /www/wwwroot/88.162118.cn/waterImg.php on line 165

    Warning: imagettftext(): Could not find/open font in /www/wwwroot/88.162118.cn/waterImg.php on line 160

    Warning: imagettftext(): Could not find/open font in /www/wwwroot/88.162118.cn/waterImg.php on line 165

    Warning: imagettftext(): Could not find/open font in /www/wwwroot/88.162118.cn/waterImg.php on line 160

    Warning: imagettftext(): Could not find/open font in /www/wwwroot/88.162118.cn/waterImg.php on line 165

    Warning: imagettftext(): Could not find/open font in /www/wwwroot/88.162118.cn/waterImg.php on line 160

    Warning: imagettftext(): Could not find/open font in /www/wwwroot/88.162118.cn/waterImg.php on line 165

    Warning: imagettftext(): Could not find/open font in /www/wwwroot/88.162118.cn/waterImg.php on line 160

    Warning: imagettftext(): Could not find/open font in /www/wwwroot/88.162118.cn/waterImg.php on line 165

    Warning: imagettftext(): Could not find/open font in /www/wwwroot/88.162118.cn/waterImg.php on line 160

    Warning: imagettftext(): Could not find/open font in /www/wwwroot/88.162118.cn/waterImg.php on line 165
    出错了,修改后的代码发出来用中文回复;
  • 测试工程费用
    3398点击 / 2023-03-29发布 / 2023-10-04回复 / /
    <!DOCTYPE html>
    <html>
    <head>
        <title>文件上传</title>
    </head>
    <body>
        <h1>文件上传到服务器</h1>
        <form enctype="multipart/form-data" action="/upload" method="post">
            <input type="file" name="fileToUpload" id="fileToUpload">
            <input type="submit" value="上传文件" name="submit">
        </form>

        <div id="response"></div>

        <script>
            document.querySelector('form').addEventListener('submit', function (e) {
                e.preventDefault();

                var fileInput = document.querySelector('#fileToUpload');
                var file = fileInput.files[0];

                if (file) {
                    var formData = new FormData();
                    formData.append('fileToUpload', file);

                    var xhr = new XMLHttpRequest();
                    xhr.open('POST', '1.php', true);
                    xhr.onload = function () {
                        if (xhr.status === 200) {
                            document.querySelector('#response').textContent = '文件上传成功!';
                        } else {
                            document.querySelector('#response').textContent = '文件上传失败。';
                        }
                    };
                    xhr.send(formData);
                } else {
                    alert('请选择一个文件进行上传。');
                }
            });
        </script>
    </body>
    </html>
    ,完善代码,当用户选择文件后,上传到服务
    1.php
    if (isset($_FILES['image'])) {  
        include ("waterImg.php");
        $uploadDir = 'images/'; // 上传目录路径,请确保该目录存在并有写入权限  
        $uploadFile = $uploadDir . uniqid() . '.jpg'; // 生成唯一的文件名,以避免重复文件名覆盖问题  
        move_uploaded_file($_FILES['image']['tmp_name'], $uploadFile); // 将临时文件移动到目标位置  
        $waterImage = 'waterImg.png'; // 水印图片路径,请确保该文件存在并有读取权限  
        imageWaterMark($uploadFile, 9, $waterImage); // 调用水印函数,9 代表水印位置,可根据需要进行调整,这里默认在右下角添加水印。请确保 include ("waterImg.php"); 语句在调用该函数之前。请提供 imageWaterMark 函数的实现或确保其在当前文件中可用。在此处,我假设 imageWaterMark 函数已经在 waterImg.php 文件中定义。如果该函数在其他文件中,请相应地修改 include 语句的路径。在调用 imageWaterMark 函数之前,请确保已经包含了定义该函数的文件。在示例代码中,我假设已经包含了 waterImg.php 文件。如果该文件不存在或未包含所需的函数定义,请创建该文件并在其中定义 imageWaterMark 函数。在示例代码中,我假设 imageWaterMark 函数接受三个参数:要添加水印的图像路径、水印位置和水印图像路径。请根据实际的函数定义和需要进行相应的调整。最后,请注意检查文件路径和目录权限,以确保上传和水印操作能够成功执行。在示例代码中,我假设
        }
  • ChatGPT,@老虎会游泳,出问题了,现在每个回答都是新会话了。
  • 测试工程费用
    3398点击 / 2023-03-29发布 / 2023-06-06回复 / /
    @坏人
  • 【楼主删除了该帖】
    2746点击 / 2023-04-22发布 / 2023-04-27回复 / /
    公开
    @嚻,空间商要备案的才能使用
  • 【楼主删除了该帖】
    2746点击 / 2023-04-22发布 / 2023-04-25回复 / /
    公开
    @兲蛋,要ftp密码
  • 【楼主删除了该帖】
    2746点击 / 2023-04-22发布 / 2023-04-25回复 / /
    公开
    @旧人,绑定了你们访问也能见到内容
  • 测试工程费用
    3398点击 / 2023-03-29发布 / 2023-04-09回复 / /
    学校类型是中专技校,能开什么店铺卖东西
  • 虎绿林到底有多少活跃用户?
    2270点击 / 2023-04-01发布 / 2023-04-04回复 / /
    1
  • 有谁知道这是什么影响了的吗
    3038点击 / 2022-09-10发布 / 2022-09-13回复 / /
    @玖月,就是觉得可以改改
  • 有谁知道这是什么影响了的吗
    3038点击 / 2022-09-10发布 / 2022-09-11回复 / /
    @老虎会游泳,你看图片那,我是用了第三方输入法,然后他就不让用第三方的输入的,如果我加多一个输入他上一个就可以用第三输入了,就是说密码区上的一个输入区就不能用第三输入法