最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php gd等比例縮放壓縮圖片函數(shù)

 更新時間:2016年06月12日 14:47:58   作者:@mezongzi  
這篇文章主要為大家詳細介紹了php gd等比例縮放壓縮圖片函數(shù),文章末尾為大家分享了php and gd 函數(shù)參考表,感興趣的小伙伴們可以參考一下

本文實例為大家分享了php gd等比例縮放壓縮圖片函數(shù),供大家參考,具體內(nèi)容如下

<?php
  /**
   * desription 判斷是否gif動畫
   * @param sting $image_file圖片路徑
   * @return boolean t 是 f 否
   */
  function check_gifcartoon($image_file){
    $fp = fopen($image_file,'rb');
    $image_head = fread($fp,1024);
    fclose($fp);
    return preg_match("/".chr(0x21).chr(0xff).chr(0x0b).'NETSCAPE2.0'."/",$image_head)?false:true;
  }

  /**
  * desription 壓縮圖片
  * @param sting $imgsrc 圖片路徑
  * @param string $imgdst 壓縮后保存路徑
  */
  function compressed_image($imgsrc,$imgdst){
    list($width,$height,$type)=getimagesize($imgsrc);
    $new_width = ($width>600?600:$width)*0.9;
    $new_height =($height>600?600:$height)*0.9;
    switch($type){
      case 1:
        $giftype=check_gifcartoon($imgsrc);
        if($giftype){
          header('Content-Type:image/gif');
          $image_wp=imagecreatetruecolor($new_width, $new_height);
          $image = imagecreatefromgif($imgsrc);
          imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
          //75代表的是質(zhì)量、壓縮圖片容量大小
          imagejpeg($image_wp, $imgdst,75);
          imagedestroy($image_wp);
        }
        break;
      case 2:
        header('Content-Type:image/jpeg');
        $image_wp=imagecreatetruecolor($new_width, $new_height);
        $image = imagecreatefromjpeg($imgsrc);
        imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
        //75代表的是質(zhì)量、壓縮圖片容量大小
        imagejpeg($image_wp, $imgdst,75);
        imagedestroy($image_wp);
        break;
      case 3:
        header('Content-Type:image/png');
        $image_wp=imagecreatetruecolor($new_width, $new_height);
        $image = imagecreatefrompng($imgsrc);
        imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
        //75代表的是質(zhì)量、壓縮圖片容量大小
        imagejpeg($image_wp, $imgdst,75);
        imagedestroy($image_wp);
        break;
    }
  }

php and gd 函數(shù)參考表
gd_info 取得當(dāng)前安裝的 GD 庫的信息
getimagesize 取得圖像大小
getimagesizefromstring Get the size of an image from a string
image_type_to_extension 取得圖像類型的文件后綴
image_type_to_mime_type 取得 getimagesize,exif_read_data,exif_thumbnail,exif_imagetype 所返回的圖像類型的 MIME 類型
image2wbmp 以 WBMP 格式將圖像輸出到瀏覽器或文件
imageaffine Return an image containing the affine tramsformed src image, using an optional clipping area
imageaffinematrixconcat Concat two matrices (as in doing many ops in one go)
imageaffinematrixget Return an image containing the affine tramsformed src image, using an optional clipping area
imagealphablending 設(shè)定圖像的混色模式
imageantialias 是否使用抗鋸齒(antialias)功能
imagearc 畫橢圓弧
imagechar 水平地畫一個字符
imagecharup 垂直地畫一個字符
imagecolorallocate 為一幅圖像分配顏色
imagecolorallocatealpha 為一幅圖像分配顏色 + alpha
imagecolorat 取得某像素的顏色索引值
imagecolorclosest 取得與指定的顏色最接近的顏色的索引值
imagecolorclosestalpha 取得與指定的顏色加透明度最接近的顏色
imagecolorclosesthwb 取得與給定顏色最接近的色度的黑白色的索引
imagecolordeallocate 取消圖像顏色的分配
imagecolorexact 取得指定顏色的索引值
imagecolorexactalpha 取得指定的顏色加透明度的索引值
imagecolormatch 使一個圖像中調(diào)色板版本的顏色與真彩色版本更能匹配
imagecolorresolve 取得指定顏色的索引值或有可能得到的最接近的替代值
imagecolorresolvealpha 取得指定顏色 + alpha 的索引值或有可能得到的最接近的替代值
imagecolorset 給指定調(diào)色板索引設(shè)定顏色
imagecolorsforindex 取得某索引的顏色
imagecolorstotal 取得一幅圖像的調(diào)色板中顏色的數(shù)目
imagecolortransparent 將某個顏色定義為透明色
imageconvolution 用系數(shù) div 和 offset 申請一個 3x3 的卷積矩陣
imagecopy 拷貝圖像的一部分
imagecopymerge 拷貝并合并圖像的一部分
imagecopymergegray 用灰度拷貝并合并圖像的一部分
imagecopyresampled 重采樣拷貝部分圖像并調(diào)整大小
imagecopyresized 拷貝部分圖像并調(diào)整大小
imagecreate 新建一個基于調(diào)色板的圖像
imagecreatefromgd2 從 GD2 文件或 URL 新建一圖像
imagecreatefromgd2part 從給定的 GD2 文件或 URL 中的部分新建一圖像
imagecreatefromgd 從 GD 文件或 URL 新建一圖像
imagecreatefromgif 由文件或 URL 創(chuàng)建一個新圖象。
imagecreatefromjpeg 由文件或 URL 創(chuàng)建一個新圖象。
imagecreatefrompng 由文件或 URL 創(chuàng)建一個新圖象。
imagecreatefromstring 從字符串中的圖像流新建一圖像
imagecreatefromwbmp 由文件或 URL 創(chuàng)建一個新圖象。
imagecreatefromwebp 由文件或 URL 創(chuàng)建一個新圖象。
imagecreatefromxbm 由文件或 URL 創(chuàng)建一個新圖象。
imagecreatefromxpm 由文件或 URL 創(chuàng)建一個新圖象。
imagecreatetruecolor 新建一個真彩色圖像
imagecrop Crop an image using the given coordinates and size, x, y, width and height
imagecropauto Crop an image automatically using one of the available modes
imagedashedline 畫一虛線
imagedestroy 銷毀一圖像
imageellipse 畫一個橢圓
imagefill 區(qū)域填充
imagefilledarc 畫一橢圓弧且填充
imagefilledellipse 畫一橢圓并填充
imagefilledpolygon 畫一多邊形并填充
imagefilledrectangle 畫一矩形并填充
imagefilltoborder 區(qū)域填充到指定顏色的邊界為止
imagefilter 對圖像使用過濾器
imageflip Flips an image using a given mode
imagefontheight 取得字體高度
imagefontwidth 取得字體寬度
imageftbbox 給出一個使用 FreeType 2 字體的文本框
imagefttext 使用 FreeType 2 字體將文本寫入圖像
imagegammacorrect 對 GD 圖像應(yīng)用 gamma 修正
imagegd2 將 GD2 圖像輸出到瀏覽器或文件
imagegd 將 GD 圖像輸出到瀏覽器或文件
imagegif 輸出圖象到瀏覽器或文件。
imagegrabscreen Captures the whole screen
imagegrabwindow Captures a window
imageinterlace 激活或禁止隔行掃描
imageistruecolor 檢查圖像是否為真彩色圖像
imagejpeg 輸出圖象到瀏覽器或文件。
imagelayereffect 設(shè)定 alpha 混色標(biāo)志以使用綁定的 libgd 分層效果
imageline 畫一條線段
imageloadfont 載入一新字體
imagepalettecopy 將調(diào)色板從一幅圖像拷貝到另一幅
imagepalettetotruecolor Converts a palette based image to true color
imagepng 以 PNG 格式將圖像輸出到瀏覽器或文件
imagepolygon 畫一個多邊形
imagepsbbox 給出一個使用 PostScript Type1 字體的文本方框
imagepsencodefont 改變字體中的字符編碼矢量
imagepsextendfont 擴充或精簡字體
imagepsfreefont 釋放一個 PostScript Type 1 字體所占用的內(nèi)存
imagepsloadfont 從文件中加載一個 PostScript Type 1 字體
imagepsslantfont 傾斜某字體
imagepstext 用 PostScript Type1 字體把文本字符串畫在圖像上
imagerectangle 畫一個矩形
imagerotate 用給定角度旋轉(zhuǎn)圖像
imagesavealpha 設(shè)置標(biāo)記以在保存 PNG 圖像時保存完整的 alpha 通道信息(與單一透明色相反)
imagescale Scale an image using the given new width and height
imagesetbrush 設(shè)定畫線用的畫筆圖像
imagesetinterpolation Set the interpolation method
imagesetpixel 畫一個單一像素
imagesetstyle 設(shè)定畫線的風(fēng)格
imagesetthickness 設(shè)定畫線的寬度
imagesettile 設(shè)定用于填充的貼圖
imagestring 水平地畫一行字符串
imagestringup 垂直地畫一行字符串
imagesx 取得圖像寬度
imagesy 取得圖像高度
imagetruecolortopalette 將真彩色圖像轉(zhuǎn)換為調(diào)色板圖像
imagettfbbox 取得使用 TrueType 字體的文本的范圍
imagettftext 用 TrueType 字體向圖像寫入文本
imagetypes 返回當(dāng)前 PHP 版本所支持的圖像類型
imagewbmp 以 WBMP 格式將圖像輸出到瀏覽器或文件
imagewebp Output an WebP image to browser or file
imagexbm 將 XBM 圖像輸出到瀏覽器或文件
iptcembed 將二進制 IPTC 數(shù)據(jù)嵌入到一幅 JPEG 圖像中
iptcparse 將二進制 IPTC 塊解析為單個標(biāo)記
jpeg2wbmp 將 JPEG 圖像文件轉(zhuǎn)換為 WBMP 圖像文件
png2wbmp 將 PNG 圖像文件轉(zhuǎn)換為 WBMP 圖像文件

以上就是本文的全部內(nèi)容,希望對大家學(xué)習(xí)PHP程序設(shè)計有所幫助。

相關(guān)文章

  • ecshop 訂單確認中顯示省市地址信息的方法

    ecshop 訂單確認中顯示省市地址信息的方法

    ecshop的購物流程中最后的訂單確認信息,其中關(guān)于用戶訂單配送地址信息,沒有包含用戶選擇的省市縣區(qū)信息。
    2010-03-03
  • Nginx環(huán)境下PHP flush失效的解決方法

    Nginx環(huán)境下PHP flush失效的解決方法

    最近在工作中發(fā)現(xiàn)了一個問題,PHP的flush居然失效了,從網(wǎng)上找了一些資料,發(fā)現(xiàn)是Nginx的原因,所以這篇文章就給大家介紹了問題與解決辦法,有需要的朋友們下面來一起看看吧。
    2016-10-10
  • php實現(xiàn)scws中文分詞搜索的方法

    php實現(xiàn)scws中文分詞搜索的方法

    這篇文章主要介紹了php實現(xiàn)scws中文分詞搜索的方法,詳細介紹了scws中文分詞搜索的具體步驟與相關(guān)使用技巧,并提供了scws的本站下載地址,需要的朋友可以參考下
    2015-12-12
  • php 抽象類的簡單應(yīng)用

    php 抽象類的簡單應(yīng)用

    我想博客中的 文章列表和單個的文章閱讀 統(tǒng)一起來,我覺得除了sql查詢語句結(jié)構(gòu)不同,HTML代碼不同,其它也就一樣。不過話說回來,這兩個都是主要功能,所以這的確有點不適合,不過昨晚讀了一點設(shè)計模式,好歹得寫點啥好。
    2011-09-09
  • PHP加密解密實例分析

    PHP加密解密實例分析

    這篇文章主要介紹了PHP加密解密實現(xiàn)方法,結(jié)合實例形式分析了PHP自定義函數(shù)實現(xiàn)字符串加密與對應(yīng)解密的相關(guān)技巧,需要的朋友可以參考下
    2015-12-12
  • PHP文件上傳利用的常見函數(shù)總結(jié)大全

    PHP文件上傳利用的常見函數(shù)總結(jié)大全

    文件上傳是開發(fā)中常見的一個功能,下面這篇文章主要給大家介紹了關(guān)于PHP文件上傳利用的常見函數(shù),文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下
    2022-03-03
  • PHP實現(xiàn)將textarea的值根據(jù)回車換行拆分至數(shù)組

    PHP實現(xiàn)將textarea的值根據(jù)回車換行拆分至數(shù)組

    這篇文章主要介紹了PHP實現(xiàn)將textarea的值根據(jù)回車換行拆分至數(shù)組,涉及表單元素及explode拆分字符串的相關(guān)技巧,需要的朋友可以參考下
    2015-06-06
  • mysq GBKl亂碼

    mysq GBKl亂碼

    mysq GBKl亂碼...
    2006-11-11
  • 解決php-fpm.service not found問題的辦法

    解決php-fpm.service not found問題的辦法

    這篇文章主要給大家介紹了解決php-fpm.service not found問題的辦法,文中詳細介紹的解決這個問題的思路與過程,分享出來給大家,如果有同樣問題的朋友就不用到處找解決辦法了,下面來一起看看吧。
    2017-06-06
  • php 判斷字符串中是否包含html標(biāo)簽

    php 判斷字符串中是否包含html標(biāo)簽

    本篇文章主要是對使用php判斷字符串中是否包含html標(biāo)簽的實例代碼進行了介紹,需要的朋友可以過來參考下,希望對大家有所幫助
    2014-02-02

最新評論

庆阳市| 拉萨市| 屏东县| 思茅市| 棋牌| 阿克| 玉门市| 新蔡县| 从化市| 冕宁县| 凌海市| 长治市| 电白县| 娄烦县| 蚌埠市| 板桥市| 朝阳市| 高安市| 会东县| 科尔| 平凉市| 淮阳县| 甘谷县| 寻乌县| 兰州市| 乐陵市| 杭锦旗| 肃宁县| 吴忠市| 蓬安县| 巫山县| 武平县| 和平区| 金湖县| 石家庄市| 民县| 惠州市| 沙洋县| 张北县| 双城市| 额济纳旗|