当前位置: 首页>>代码示例>>PHP>>正文


PHP cls_image::add_watermark方法代码示例

本文整理汇总了PHP中cls_image::add_watermark方法的典型用法代码示例。如果您正苦于以下问题:PHP cls_image::add_watermark方法的具体用法?PHP cls_image::add_watermark怎么用?PHP cls_image::add_watermark使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cls_image的用法示例。


在下文中一共展示了cls_image::add_watermark方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: SaveHTTPFile

function SaveHTTPFile($fFileHTTPPath, $fFileSavePath, $fFileSaveName)
{
    //记录程序开始的时间
    $BeginTime = getmicrotime();
    //取得文件名
    $fFileSaveName = $fFileSavePath . "/" . $fFileSaveName;
    make_dir(dirname($fFileSaveName));
    //取得文件的内容
    ob_start();
    readfile($fFileHTTPPath);
    $img = ob_get_contents();
    ob_end_clean();
    //$size = strlen($img);
    //保存到本地
    $fp2 = @fopen($fFileSaveName, "a");
    fwrite($fp2, $img);
    fclose($fp2);
    /*加水印代码*/
    require_once ROOT_PATH . 'includes/cls_image.php';
    $ext = get_extension($fFileSaveName);
    $fFileSaveName = convert_GIF_to_JPG($fFileSaveName);
    if (CopyFiles($fFileSaveName)) {
        $image = new cls_image();
        $image->add_watermark($fFileSaveName, '', '../../../../' . $GLOBALS['waterMark']['watermark'], $GLOBALS['waterMark']['watermark_place'], $GLOBALS['waterMark']['watermark_alpha']);
    }
    if ($ext == 'gif' || $ext == '.gif') {
        back_JPG_to_GIF($fFileSaveName);
    }
    /*加水印代码--end*/
    //记录程序运行结束的时间
    $EndTime = getmicrotime();
    //返回运行时间
    return $EndTime - $BeginTime;
}
开发者ID:norain2050,项目名称:benhu,代码行数:34,代码来源:ServerXMLHTTP.php

示例2: array

 if ($image->gd_version() > 0 && $image->check_img_function($_FILES['goods_img']['type'])) {
     // 如果设置大小不为0,缩放图片
     if ($_CFG['image_width'] != 0 || $_CFG['image_height'] != 0) {
         $goods_img = $image->make_thumb('../' . $goods_img, $GLOBALS['_CFG']['image_width'], $GLOBALS['_CFG']['image_height']);
         if ($goods_img === false) {
             sys_msg($image->error_msg(), 1, array(), false);
         }
     }
     $newname = dirname($img) . '/' . $image->random_filename() . substr(basename($img), $pos);
     if (!copy('../' . $img, '../' . $newname)) {
         sys_msg('fail to copy file: ' . realpath('../' . $img), 1, array(), false);
     }
     $gallery_img = $newname;
     // 加水印
     if (intval($_CFG['watermark_place']) > 0 && !empty($GLOBALS['_CFG']['watermark'])) {
         if ($image->add_watermark('../' . $goods_img, '', $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']) === false) {
             sys_msg($image->error_msg(), 1, array(), false);
         }
         if ($image->add_watermark('../' . $gallery_img, '', $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']) === false) {
             sys_msg($image->error_msg(), 1, array(), false);
         }
     }
     // 相册缩略图
     if ($_CFG['thumb_width'] != 0 || $_CFG['thumb_height'] != 0) {
         $gallery_thumb = $image->make_thumb('../' . $img, $GLOBALS['_CFG']['thumb_width'], $GLOBALS['_CFG']['thumb_height']);
         if ($gallery_thumb === false) {
             sys_msg($image->error_msg(), 1, array(), false);
         }
     }
 } else {
     /* 复制一份原图 */
开发者ID:BGCX261,项目名称:zishashop-svn-to-git,代码行数:31,代码来源:index.php

示例3: API_AddGoods


//.........这里部分代码省略.........
        $original_img = upload_image($_POST['goods_img']);
        // 原始图片
        if ($original_img === false) {
            client_show_message(210);
            // 写入商品图片出错
        }
        $goods_img = $original_img;
        // 商品图片
        /* 复制一份相册图片 */
        $img = $original_img;
        // 相册图片
        $pos = strpos(basename($img), '.');
        $newname = dirname($img) . '/' . random_filename() . substr(basename($img), $pos);
        if (!copy(ROOT_PATH . '/' . $img, ROOT_PATH . '/' . $newname)) {
            client_show_message(211);
            // 复制相册图片时出错
        }
        $img = $newname;
        $gallery_img = $img;
        $gallery_thumb = $img;
        /* 图片属性 */
        $img_property = $image->gd_version() > 0 ? getimagesize(ROOT_PATH . '/' . $goods_img) : array();
        // 如果系统支持GD,缩放商品图片,且给商品图片和相册图片加水印
        if ($image->gd_version() > 0 && $image->check_img_function($img_property[2])) {
            // 如果设置大小不为0,缩放图片
            if ($GLOBALS['_CFG']['image_width'] != 0 || $GLOBALS['_CFG']['image_height'] != 0) {
                $goods_img = $image->make_thumb(ROOT_PATH . '/' . $goods_img, $GLOBALS['_CFG']['image_width'], $GLOBALS['_CFG']['image_height']);
                if ($goods_img === false) {
                    client_show_message(212);
                }
            }
            // 加水印
            if (intval($GLOBALS['_CFG']['watermark_place']) > 0 && !empty($GLOBALS['_CFG']['watermark'])) {
                if ($image->add_watermark(ROOT_PATH . '/' . $goods_img, '', $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']) === false) {
                    client_show_message(213);
                }
                $newname = dirname($img) . '/' . random_filename() . substr(basename($img), $pos);
                if (!copy(ROOT_PATH . '/' . $img, ROOT_PATH . '/' . $newname)) {
                    client_show_message(214);
                }
                $gallery_img = $newname;
                if ($image->add_watermark(ROOT_PATH . '/' . $gallery_img, '', $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']) === false) {
                    client_show_message(213);
                }
            }
            // 相册缩略图
            if ($_CFG['thumb_width'] != 0 || $_CFG['thumb_height'] != 0) {
                $gallery_thumb = $image->make_thumb(ROOT_PATH . '/' . $img, $GLOBALS['_CFG']['thumb_width'], $GLOBALS['_CFG']['thumb_height']);
                if ($gallery_thumb === false) {
                    client_show_message(215);
                }
            }
        }
    }
    if (!empty($_POST['goods_thumb']['Data'])) {
        if (!in_array($_POST['goods_thumb']['Type'], $allow_file_type)) {
            client_show_message(203);
        }
        if (client_check_image_size($_POST['goods_thumb']['Data']) === false) {
            client_show_message(204);
        }
        $goods_thumb = upload_image($_POST['goods_thumb']);
        if ($goods_thumb === false) {
            client_show_message(217);
        }
    } else {
开发者ID:Ryan007,项目名称:mybb,代码行数:67,代码来源:lib_api.php

示例4: MoreFileUpload

function MoreFileUpload($resourceType, $currentFolder, $sCommand)
{
    if (!isset($_FILES)) {
        global $_FILES;
    }
    global $Config;
    $sErrorNumber = '0';
    $sFileName = '';
    if (is_array($_FILES['NewFile']['name'])) {
        foreach ($_FILES['NewFile']['name'] as $key => $value) {
            if (!empty($_FILES['NewFile']['tmp_name'][$key])) {
                // Map the virtual path to the local server path.
                $sServerDir = ServerMapFolder($resourceType, $currentFolder, $sCommand);
                // Get the uploaded file name.
                $sFileName = $_FILES['NewFile']['name'][$key];
                $sFileName = SanitizeFileName($sFileName);
                $sOriginalFileName = $sFileName;
                // Get the extension.
                $sExtension = substr($sFileName, strrpos($sFileName, '.') + 1);
                $sExtension = strtolower($sExtension);
                if (isset($Config['SecureImageUploads'])) {
                    if (($isImageValid = IsImageValid($_FILES['NewFile']['tmp_name'][$key], $sExtension)) === false) {
                        $sErrorNumber = '202';
                    }
                }
                if (isset($Config['HtmlExtensions'])) {
                    if (!IsHtmlExtension($sExtension, $Config['HtmlExtensions']) && ($detectHtml = DetectHtml($_FILES['NewFile']['tmp_name'][$key])) === true) {
                        $sErrorNumber = '202';
                    }
                }
                // Check if it is an allowed extension.
                if (!$sErrorNumber && IsAllowedExt($sExtension, $resourceType)) {
                    $iCounter = 0;
                    while (true) {
                        $sFilePath = $sServerDir . $sFileName;
                        if (is_file($sFilePath)) {
                            $iCounter++;
                            $sFileName = RemoveExtension($sOriginalFileName) . '(' . $iCounter . ').' . $sExtension;
                            $sErrorNumber = '201';
                        } else {
                            move_uploaded_file($_FILES['NewFile']['tmp_name'][$key], $sFilePath);
                            //判断并给符合条件图片加上水印
                            if ($sExtension == 'jpg' || $sExtension == 'jpeg' || $sExtension == 'png' || $sExtension == 'gif' || $sExtension == 'bmp') {
                                require_once ROOT_PATH . '/includes/cls_image.php';
                                $image = new cls_image($GLOBALS['_CFG']['bgcolor']);
                                if (intval($GLOBALS['_CFG']['watermark_place']) > 0 && !empty($GLOBALS['_CFG']['watermark'])) {
                                    $image->add_watermark($sFilePath, '', '../../../../../' . $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']);
                                }
                            }
                            if (is_file($sFilePath)) {
                                if (isset($Config['ChmodOnUpload']) && !$Config['ChmodOnUpload']) {
                                    break;
                                }
                                $permissions = 0777;
                                if (isset($Config['ChmodOnUpload']) && $Config['ChmodOnUpload']) {
                                    $permissions = $Config['ChmodOnUpload'];
                                }
                                $oldumask = umask(0);
                                chmod($sFilePath, $permissions);
                                umask($oldumask);
                            }
                            break;
                        }
                    }
                    if (file_exists($sFilePath)) {
                        //previous checks failed, try once again
                        if (isset($isImageValid) && $isImageValid === -1 && IsImageValid($sFilePath, $sExtension) === false) {
                            @unlink($sFilePath);
                            $sErrorNumber = '202';
                        } else {
                            if (isset($detectHtml) && $detectHtml === -1 && DetectHtml($sFilePath) === true) {
                                @unlink($sFilePath);
                                $sErrorNumber = '202';
                            }
                        }
                    }
                } else {
                    $sErrorNumber = '202';
                }
                if ($sErrorNumber == '202') {
                    $sFileUrl = CombinePaths(GetResourceTypePath($resourceType, $sCommand), $currentFolder);
                    $sFileUrl = CombinePaths($sFileUrl, $sFileName);
                    SendUploadResults($sErrorNumber, $sFileUrl, $sFileName);
                }
            } else {
                continue;
            }
        }
        $sFileUrl = CombinePaths(GetResourceTypePath($resourceType, $sCommand), $currentFolder);
        $sFileUrl = CombinePaths($sFileUrl, $sFileName);
        SendUploadResults($sErrorNumber, $sFileUrl, $sFileName, $key);
    } else {
        $sErrorNumber = '202';
        $sFileUrl = CombinePaths(GetResourceTypePath($resourceType, $sCommand), $currentFolder);
        $sFileUrl = CombinePaths($sFileUrl, $sFileName);
        SendUploadResults($sErrorNumber, $sFileUrl, $sFileName);
    }
    exit;
}
开发者ID:sdssly,项目名称:port2sae,代码行数:99,代码来源:commands.php


注:本文中的cls_image::add_watermark方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。