php 給圖片加浮水印三

來源:互聯網
上載者:User

<?

function setMaskTxtPct($n)
    {
        $this->mask_txt_pct = (int)$n;
    }
 
    /**
     * 設定縮圖邊框
     *
     * @param    (類型)     (參數名)    (描述)
     */
    function setDstImgBorder($size=1, $color="#000000")
    {
        $this->img_border_size  = (int)$size;
        $this->img_border_color = $color;
    }
 
    /**
     * 水平翻轉
     */
    function flipH()
    {
        $this->_flip_x++;
    }
 
    /**
     * 垂直翻轉
     */
    function flipV()
    {
        $this->_flip_y++;
    }
 
    /**
     * 設定剪下類型
     *
     * @param    (類型)     (參數名)    (描述)
     */
    function setCutType($type)
    {
        $this->cut_type = (int)$type;
    }
 
    /**
     * 設定圖片剪下
     *
     * @param    integer     $width    矩形剪下
     */
    function setRectangleCut($width, $height)
    {
        $this->fill_w = (int)$width;
        $this->fill_h = (int)$height;
    }
 
    /**
     * 設定源圖剪下起始座標點
     *
     * @param    (類型)     (參數名)    (描述)
     */
    function setSrcCutPosition($x, $y)
    {
        $this->src_x  = (int)$x;
        $this->src_y  = (int)$y;
    }
 
    /**
     * 建立圖片,主函數
     * @param    integer    $a     當缺少第二個參數時,此參數將用作百分比,
     *                             否則作為寬度值
     * @param    integer    $b     圖片縮放後的高度
     */
    function createImg($a, $b=null)
    {
        $num = func_num_args();
        if(1 == $num)
        {
            $r = (int)$a;
            if($r < 1)
            {
                die("圖片縮放比例不得小於1");
            }
            $this->img_scale = $r;
            $this->_setNewImgSize($r);
        }
 
        if(2 == $num)
        {
            $w = (int)$a;
            $h = (int)$b;
            if(0 == $w)
            {
                die("目標寬度不能為0");
            }
            if(0 == $h)
            {
                die("目標高度不能為0");
            }
            $this->_setNewImgSize($w, $h);
        }
 
        if($this->_flip_x%2!=0)
        {
            $this->_flipH($this->h_src);
        }
 
        if($this->_flip_y%2!=0)
        {
            $this->_flipV($this->h_src);
        }
        $this->_createMask();
        $this->_output();
 
        // 釋放
        if(imagedestroy($this->h_src) && imagedestroy($this->h_dst))
        {
            Return true;
        }
        else
        {
            Return false;
        }
    }
 
   ?>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.