第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

GD庫實現(xiàn)圖片水印與縮略圖

難度初級
時長 1小時41分
學習人數(shù)
綜合評分9.77
106人評價 查看評價
9.9 內容實用
9.6 簡潔易懂
9.8 邏輯清晰
  • 注意視頻里寫的兩個info:
    函數(shù)里的$info和$this->info是不同的變量


    查看全部
  • <?php

    class Image{

    private $image;

    private $info;

    public function __construct($src)

    {

    $info2 = getimagesize($src);

    $this->info = array(

    'width' => $info2[0],

    'height' => $info2[1],

    'type' => image_type_to_extension($info2['2'],false),

    'mime' => $info2['mime']

    );

    $fun = "imagecreatefrom{$this->info['type']}";

    $this->image = $fun($src);

    }




    public function thumb($width,$height)

    {

    $image_thumb = imagecreatetruecolor($width, $height);

    imagecopyresampled($image_thumb, $this->image, 0, 0, 0, 0, $width, $height, $this->info['width'],$this->info['height']);

    imagedestroy($this->image);

    $this->image = $image_thumb;

    }


    public function show()

    {

    header("Content-type:".$this->info['mime']);

    $funs = "image{$this->info['type']}";

    $funs($this->image);

    }


    public function save($newimage)

    {

    $funs = "image{$this->info['type']}";

    $funs($this->image,$newname.'.'.$this->info['type']);

    }



    public function __destruct()

    {

    imagedestroy($this->image);

    }

    }


    ?>


    查看全部
  • AXD

    <title>給圖片添加圖片水印</title>

    <?php

    /*一、打開圖片*/


    $src = "001.png";

    $info = getimagesize($src);

    $type = image_type_to_extension($info[2],false);

    $fun = "imagecreatefrom{$type}";

    $image = $fun($src);

    /*二、操作圖片*/


    $image_Mark = "logo.png";

    $info2 = getimagesize($image_Mark);

    $type2 = image_type_to_extension($info[2],false);

    $fun2 = "imagecreatefrom{$type2}";

    $water = $fun2($image_Mark);

    //合并圖片 ?0,0,$info[0],$info[1]將水印圖片從原圖的左上角頂點開始復制,0,0代表有多高復制多高,有多寬復制多寬。

    imagecopymerge($image,$water,20,30,0,0,$info2[0],$info2[1],30);

    imagedestroy($water);

    /*三、輸出圖片*/


    ob_clean();

    header("content-type:".$info['mime']);

    $funs = "image{$type}";

    $funs($image);

    $funs($image,"hi.".$type); ?//保存圖片

    /*四、銷毀圖片*/


    imagedestroy($image);

    ?>


    查看全部
  • teat.php

    <?php?
    ????require?"image_class.php";
    ????$src?=?'1.jpg';
    ????$image?=?new?Image($src);
    ????$image->thumb(300,200);
    ????$image->show();


    查看全部
  • 我的經過測試沒有問題(代碼如下):

    <?php?
    //封裝成類-壓縮圖片
    class?Image{	
    ????private?$image;
    ????private?$info;	
    ????//1.打開一張圖片,讀取到內存中	
    ????public?function?__construct($src){		
    ????????$info?=?getimagesize($src);//獲取圖片信息放在$info里		
    ????????$this->info?=?array(			
    ????????'width'?=>?$info[0],			
    ????????'height'?=>?$info[1],			
    ????????'type'?=>?image_type_to_extension($info[2],false),			
    ????????'mime'?=>?$info['mime']);		
    ????????$fun?=?"imagecreatefrom{$this->info['type']}";		
    ????????$this->image?=?$fun($src);	}	
    ????????//2.操作圖片(壓縮)	
    ????????public?function?thumb($width,$height){		
    ????????????$image_thumb?=?imagecreatetruecolor($width,$height);		
    ????????????imagecopyresampled($image_thumb,$this->image,0,0,0,0,$width,$height,$this->info['width'],$this->info['height']);		
    ????????????imagedestroy($this->image);		
    ????????????$this->image?=?$image_thumb;	
    ????????}	
    ????????//3.在瀏覽器中輸出圖片	
    ????????public?function?show(){		
    ????????????header("Content-type:".$this->info['mime']);		
    ????????????$funs?=?"image{$this->info['type']}";		
    ????????????$funs($this->image);	
    ????????}	
    ????????//4.把圖片保存到硬盤里	
    ????????public?function?save($newname){		
    ????????????$funs?=?"image{$this->info['type']}";		
    ????????????$funs($this->image,$newname.'.'.$this->info['type']);	
    ????????}	//5.銷毀圖片	
    ????????public?function?__destruct(){		
    ????????????????imagedestroy($this->image);	
    ????????}
    ?????}


    查看全部
  • 筆記1
    查看全部
  • 成功了,代碼如下: header('Content-type:text/html;charset=utf8'); //打開圖片 $pic_src='p02.jpg'; $pic_info=getimagesize($pic_src); $pic_type=image_type_to_extension($pic_info[2],false); $fun="imagecreatefrom{$pic_type}"; $image=$fun($pic_src); //操作圖片 $font='msyh.ttf'; $content='您好,翌創(chuàng)'; $col=imagecolorallocatealpha($image,255,255,255,50); imagettftext($image,20,0,20,30,$col,$font,$content); //輸出圖片 header("Content-type:".$pic_info['mime']); $func="image{$pic_type}"; $func($image); //保存圖片 $func($image,'images/new.'.$pic_type); //清理圖片 imagedestory($images);
    查看全部
  • test.php <?php require "image.class.php"; $src = "image/test.jpg"; $image = new Image($src); $image->image_Thumb(300,200); $image->image_Show(); $image->image_Destroy(); ?>
    查看全部
  • image.class.php <?php /** * 圖片工具類 */ class Image{ private $image; private $info; /** * 構造函數(shù) */ public function __construct($src){ //獲取圖片信息 $info = getimagesize($src); $this->info = array( 'width' => $info[0], 'height' => $info[1], 'type' => image_type_to_extension($info[2],false), 'mime' => $info[3] ); //在內存中創(chuàng)建一個相同類型的圖片 $new_cache = "imagecreatefrom{$this->info['type']}"; $this->image = $new_cache($src); }
    查看全部
  • /** * 操作圖片 縮略圖 */ public function image_Thumb($dstWidth,$dstHeight){ $image_thumb = imagecreatetruecolor($dstWidth,$dstHeight); imagecopyresampled($image_thumb,$this->image,0,0,0,0,$dstWidth,$dstHeight,$this->info['width'],$this->info['height']); //原始圖片已使用完畢 可以銷毀 imagedestroy($this->image); $this->image = $image_thumb; } /** * 顯示圖片 */ public function image_Show(){ header("content-type:".$this->info['mime']); $new_cache = "image{$this->info['type']}"; $new_cache($this->image); } /** * 銷毀圖片 */ public function image_Destroy(){ imagedestroy($this->image); } } ?>
    查看全部
  • <?php /*打開圖片*/ //1.配置圖片路徑 $src_url = "image/GD_test.png"; //2.獲取圖片信息 $info = getimagesize($src_url); // echo "<pre>"; //print_r($info); //3.通過圖片編號來確認圖片類型,取消false參數(shù)獲取值為 .png ; $type = image_type_to_extension($info[2],false); // print_r($type); //4.在內存中創(chuàng)建一個和打開圖片類型一樣的圖像 $fun = "imagecreatefrom{$type}"; //相當于 $fun = imagecreatefrompng(); //5.把圖片復制到內存中 $image = $fun($src_url); //相當于 imagecreatefrompng($src) /*操作圖片*/ //1.設置字體路徑 $font = "image/msyhl.ttc"; //2.填寫水印內容 $content = "xiaoweiba.ml"; //3.設置字體顏色RGB值和透明度, //參數(shù)1:內存中的圖片; 參數(shù)2:顏色; 參數(shù)3:透明度 //注意?。?! png圖片無法正常渲染字體顏色?。。?! $col = imagecolorallocatealpha($image,0,0,0,15);
    查看全部
  • imagettftext($image,20,0,20,30,$col,$font,$content); /*輸出圖片*/ //1.瀏覽器輸出 header("Content-type:".$info['mime']); $func = "image{$type}"; //如果是jpeg就調用 imagejpeg()方法,如果是peg就會調用imagepng()方法 $func($image); //2.保存圖片 $func($image,'image/newimage.'.$type); //imagepng($image,'image/newimage.png'); //顯示圖片 //輸出生成的圖片,配置文件路徑 $src_new = "image/newimage.png"; //無法直接輸出圖片,必須將圖片復制到內存中。 $fun_new = imagecreatefrompng($src_new); //輸出圖片 imagepng($fun_new); // imagepng(imagecreatefrompng("image/newimage.png")); /*銷毀圖片*/ imagedestroy($image); imagedestroy($fun_new); ?>
    查看全部
  • /* 輸出圖片 */ public function show() { header("Content-type:".$this->info['mime']); $funs="image{$this->info['type']}"; $funs($this->image); } /* 保存圖片 */ public function save($newImage) { $funs="image{$this->info['type']}"; $funs($this->image,$newImage.'.'.$this->info['type']); } /* 銷毀圖片 */ public function __destruct() { imagedestroy($this->image); } } ?>
    查看全部
首頁上一頁1234567下一頁尾頁

舉報

0/150
提交
取消
課程須知
學習本門課程之前,建議先了解一下知識,會更有助于理解和掌握本門課程 1、掌握PHP基本的語言語法 2、了解PHP生命周期與PHP運行環(huán)境 3、有一定編程基礎
老師告訴你能學到什么?
1、加深對GD庫的了解 2、利用GD庫給圖片添加文字和圖片水印 3、利用GD庫壓縮圖片 5、如何打造一個屬于自己的工具類

微信掃碼,參與3人拼團

微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

友情提示:

您好,此課程屬于遷移課程,您已購買該課程,無需重復購買,感謝您對慕課網的支持!