<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                要激活 GD 支持,配置 PHP 時加上**\--with-gd\[=DIR\]**,DIR 是 GD 的基本安裝目錄。要使用推薦的綁定的 GD 庫版本(首次綁定于 PHP 4.3.0),使用**\--with-gd**。要編譯 GD 庫,需要libpng和libjpeg。 windows啟用php_gd2.dll 要想在 PHP 中使用圖像處理功能,你需要連帶GD庫一起來編譯 PHP。GD庫和 PHP 可能需要其他的庫, 這取決于你要處理的圖像格式 * [范例](https://www.php.net/manual/zh/image.examples.php) * [使用 PHP 創建 PNG 圖像](https://www.php.net/manual/zh/image.examples-png.php) * [使用 Alpha 通道為圖像加水印](https://www.php.net/manual/zh/image.examples-watermark.php) * [使用 imagecopymerge 函數創建半透明水印](https://www.php.net/manual/zh/image.examples.merged-watermark.php) * [GD 和圖像處理 函數](https://www.php.net/manual/zh/ref.image.php) * [gd\_info](https://www.php.net/manual/zh/function.gd-info.php)— 取得當前安裝的 GD 庫的信息 * [getimagesize](https://www.php.net/manual/zh/function.getimagesize.php)— 取得圖像大小 * [getimagesizefromstring](https://www.php.net/manual/zh/function.getimagesizefromstring.php)— 從字符串中獲取圖像尺寸信息 * [image\_type\_to\_extension](https://www.php.net/manual/zh/function.image-type-to-extension.php)— 取得圖像類型的文件后綴 * [image\_type\_to\_mime\_type](https://www.php.net/manual/zh/function.image-type-to-mime-type.php)— 取得 getimagesize,exif\_read\_data,exif\_thumbnail,exif\_imagetype 所返回的圖像類型的 MIME 類型 * [image2wbmp](https://www.php.net/manual/zh/function.image2wbmp.php)— 以 WBMP 格式將圖像輸出到瀏覽器或文件 * [imageaffine](https://www.php.net/manual/zh/function.imageaffine.php)— 返回經過仿射變換后的圖像,剪切區域可選 * [imageaffinematrixconcat](https://www.php.net/manual/zh/function.imageaffinematrixconcat.php)— Concatenate two affine transformation matrices * [imageaffinematrixget](https://www.php.net/manual/zh/function.imageaffinematrixget.php)— Get an affine transformation matrix * [imagealphablending](https://www.php.net/manual/zh/function.imagealphablending.php)— 設定圖像的混色模式 * [imageantialias](https://www.php.net/manual/zh/function.imageantialias.php)— 是否使用抗鋸齒(antialias)功能 * [imagearc](https://www.php.net/manual/zh/function.imagearc.php)— 畫橢圓弧 * [imagebmp](https://www.php.net/manual/zh/function.imagebmp.php)— Output a BMP image to browser or file * [imagechar](https://www.php.net/manual/zh/function.imagechar.php)— 水平地畫一個字符 * [imagecharup](https://www.php.net/manual/zh/function.imagecharup.php)— 垂直地畫一個字符 * [imagecolorallocate](https://www.php.net/manual/zh/function.imagecolorallocate.php)— 為一幅圖像分配顏色 * [imagecolorallocatealpha](https://www.php.net/manual/zh/function.imagecolorallocatealpha.php)— 為一幅圖像分配顏色 + alpha * [imagecolorat](https://www.php.net/manual/zh/function.imagecolorat.php)— 取得某像素的顏色索引值 * [imagecolorclosest](https://www.php.net/manual/zh/function.imagecolorclosest.php)— 取得與指定的顏色最接近的顏色的索引值 * [imagecolorclosestalpha](https://www.php.net/manual/zh/function.imagecolorclosestalpha.php)— 取得與指定的顏色加透明度最接近的顏色 * [imagecolorclosesthwb](https://www.php.net/manual/zh/function.imagecolorclosesthwb.php)— 取得與給定顏色最接近的色度的黑白色的索引 * [imagecolordeallocate](https://www.php.net/manual/zh/function.imagecolordeallocate.php)— 取消圖像顏色的分配 * [imagecolorexact](https://www.php.net/manual/zh/function.imagecolorexact.php)— 取得指定顏色的索引值 * [imagecolorexactalpha](https://www.php.net/manual/zh/function.imagecolorexactalpha.php)— 取得指定的顏色加透明度的索引值 * [imagecolormatch](https://www.php.net/manual/zh/function.imagecolormatch.php)— 使一個圖像中調色板版本的顏色與真彩色版本更能匹配 * [imagecolorresolve](https://www.php.net/manual/zh/function.imagecolorresolve.php)— 取得指定顏色的索引值或有可能得到的最接近的替代值 * [imagecolorresolvealpha](https://www.php.net/manual/zh/function.imagecolorresolvealpha.php)— 取得指定顏色 + alpha 的索引值或有可能得到的最接近的替代值 * [imagecolorset](https://www.php.net/manual/zh/function.imagecolorset.php)— 給指定調色板索引設定顏色 * [imagecolorsforindex](https://www.php.net/manual/zh/function.imagecolorsforindex.php)— 取得某索引的顏色 * [imagecolorstotal](https://www.php.net/manual/zh/function.imagecolorstotal.php)— 取得一幅圖像的調色板中顏色的數目 * [imagecolortransparent](https://www.php.net/manual/zh/function.imagecolortransparent.php)— 將某個顏色定義為透明色 * [imageconvolution](https://www.php.net/manual/zh/function.imageconvolution.php)— 用系數 div 和 offset 申請一個 3x3 的卷積矩陣 * [imagecopy](https://www.php.net/manual/zh/function.imagecopy.php)— 拷貝圖像的一部分 * [imagecopymerge](https://www.php.net/manual/zh/function.imagecopymerge.php)— 拷貝并合并圖像的一部分 * [imagecopymergegray](https://www.php.net/manual/zh/function.imagecopymergegray.php)— 用灰度拷貝并合并圖像的一部分 * [imagecopyresampled](https://www.php.net/manual/zh/function.imagecopyresampled.php)— 重采樣拷貝部分圖像并調整大小 * [imagecopyresized](https://www.php.net/manual/zh/function.imagecopyresized.php)— 拷貝部分圖像并調整大小 * [imagecreate](https://www.php.net/manual/zh/function.imagecreate.php)— 新建一個基于調色板的圖像 * [imagecreatefrombmp](https://www.php.net/manual/zh/function.imagecreatefrombmp.php)— 由文件或 URL 創建一個新圖象。 * [imagecreatefromgd2](https://www.php.net/manual/zh/function.imagecreatefromgd2.php)— 從 GD2 文件或 URL 新建一圖像 * [imagecreatefromgd2part](https://www.php.net/manual/zh/function.imagecreatefromgd2part.php)— 從給定的 GD2 文件或 URL 中的部分新建一圖像 * [imagecreatefromgd](https://www.php.net/manual/zh/function.imagecreatefromgd.php)— 從 GD 文件或 URL 新建一圖像 * [imagecreatefromgif](https://www.php.net/manual/zh/function.imagecreatefromgif.php)— 由文件或 URL 創建一個新圖象。 * [imagecreatefromjpeg](https://www.php.net/manual/zh/function.imagecreatefromjpeg.php)— 由文件或 URL 創建一個新圖象。 * [imagecreatefrompng](https://www.php.net/manual/zh/function.imagecreatefrompng.php)— 由文件或 URL 創建一個新圖象。 * [imagecreatefromstring](https://www.php.net/manual/zh/function.imagecreatefromstring.php)— 從字符串中的圖像流新建一圖像 * [imagecreatefromwbmp](https://www.php.net/manual/zh/function.imagecreatefromwbmp.php)— 由文件或 URL 創建一個新圖象。 * [imagecreatefromwebp](https://www.php.net/manual/zh/function.imagecreatefromwebp.php)— 由文件或 URL 創建一個新圖象。 * [imagecreatefromxbm](https://www.php.net/manual/zh/function.imagecreatefromxbm.php)— 由文件或 URL 創建一個新圖象。 * [imagecreatefromxpm](https://www.php.net/manual/zh/function.imagecreatefromxpm.php)— 由文件或 URL 創建一個新圖象。 * [imagecreatetruecolor](https://www.php.net/manual/zh/function.imagecreatetruecolor.php)— 新建一個真彩色圖像 * [imagecrop](https://www.php.net/manual/zh/function.imagecrop.php)— Crop an image to the given rectangle * [imagecropauto](https://www.php.net/manual/zh/function.imagecropauto.php)— Crop an image automatically using one of the available modes * [imagedashedline](https://www.php.net/manual/zh/function.imagedashedline.php)— 畫一虛線 * [imagedestroy](https://www.php.net/manual/zh/function.imagedestroy.php)— 銷毀一圖像 * [imageellipse](https://www.php.net/manual/zh/function.imageellipse.php)— 畫一個橢圓 * [imagefill](https://www.php.net/manual/zh/function.imagefill.php)— 區域填充 * [imagefilledarc](https://www.php.net/manual/zh/function.imagefilledarc.php)— 畫一橢圓弧且填充 * [imagefilledellipse](https://www.php.net/manual/zh/function.imagefilledellipse.php)— 畫一橢圓并填充 * [imagefilledpolygon](https://www.php.net/manual/zh/function.imagefilledpolygon.php)— 畫一多邊形并填充 * [imagefilledrectangle](https://www.php.net/manual/zh/function.imagefilledrectangle.php)— 畫一矩形并填充 * [imagefilltoborder](https://www.php.net/manual/zh/function.imagefilltoborder.php)— 區域填充到指定顏色的邊界為止 * [imagefilter](https://www.php.net/manual/zh/function.imagefilter.php)— 對圖像使用過濾器 * [imageflip](https://www.php.net/manual/zh/function.imageflip.php)— Flips an image using a given mode * [imagefontheight](https://www.php.net/manual/zh/function.imagefontheight.php)— 取得字體高度 * [imagefontwidth](https://www.php.net/manual/zh/function.imagefontwidth.php)— 取得字體寬度 * [imageftbbox](https://www.php.net/manual/zh/function.imageftbbox.php)— 給出一個使用 FreeType 2 字體的文本框 * [imagefttext](https://www.php.net/manual/zh/function.imagefttext.php)— 使用 FreeType 2 字體將文本寫入圖像 * [imagegammacorrect](https://www.php.net/manual/zh/function.imagegammacorrect.php)— 對 GD 圖像應用 gamma 修正 * [imagegd2](https://www.php.net/manual/zh/function.imagegd2.php)— 將 GD2 圖像輸出到瀏覽器或文件 * [imagegd](https://www.php.net/manual/zh/function.imagegd.php)— 將 GD 圖像輸出到瀏覽器或文件 * [imagegetclip](https://www.php.net/manual/zh/function.imagegetclip.php)— Get the clipping rectangle * [imagegif](https://www.php.net/manual/zh/function.imagegif.php)— 輸出圖象到瀏覽器或文件。 * [imagegrabscreen](https://www.php.net/manual/zh/function.imagegrabscreen.php)— Captures the whole screen * [imagegrabwindow](https://www.php.net/manual/zh/function.imagegrabwindow.php)— Captures a window * [imageinterlace](https://www.php.net/manual/zh/function.imageinterlace.php)— 激活或禁止隔行掃描 * [imageistruecolor](https://www.php.net/manual/zh/function.imageistruecolor.php)— 檢查圖像是否為真彩色圖像 * [imagejpeg](https://www.php.net/manual/zh/function.imagejpeg.php)— 輸出圖象到瀏覽器或文件。 * [imagelayereffect](https://www.php.net/manual/zh/function.imagelayereffect.php)— 設定 alpha 混色標志以使用綁定的 libgd 分層效果 * [imageline](https://www.php.net/manual/zh/function.imageline.php)— 畫一條線段 * [imageloadfont](https://www.php.net/manual/zh/function.imageloadfont.php)— 載入一新字體 * [imageopenpolygon](https://www.php.net/manual/zh/function.imageopenpolygon.php)— Draws an open polygon * [imagepalettecopy](https://www.php.net/manual/zh/function.imagepalettecopy.php)— 將調色板從一幅圖像拷貝到另一幅 * [imagepalettetotruecolor](https://www.php.net/manual/zh/function.imagepalettetotruecolor.php)— Converts a palette based image to true color * [imagepng](https://www.php.net/manual/zh/function.imagepng.php)— 以 PNG 格式將圖像輸出到瀏覽器或文件 * [imagepolygon](https://www.php.net/manual/zh/function.imagepolygon.php)— 畫一個多邊形 * [imagepsbbox](https://www.php.net/manual/zh/function.imagepsbbox.php)— 給出一個使用 PostScript Type1 字體的文本方框 * [imagepsencodefont](https://www.php.net/manual/zh/function.imagepsencodefont.php)— 改變字體中的字符編碼矢量 * [imagepsextendfont](https://www.php.net/manual/zh/function.imagepsextendfont.php)— 擴充或精簡字體 * [imagepsfreefont](https://www.php.net/manual/zh/function.imagepsfreefont.php)— 釋放一個 PostScript Type 1 字體所占用的內存 * [imagepsloadfont](https://www.php.net/manual/zh/function.imagepsloadfont.php)— 從文件中加載一個 PostScript Type 1 字體 * [imagepsslantfont](https://www.php.net/manual/zh/function.imagepsslantfont.php)— 傾斜某字體 * [imagepstext](https://www.php.net/manual/zh/function.imagepstext.php)— 用 PostScript Type1 字體把文本字符串畫在圖像上 * [imagerectangle](https://www.php.net/manual/zh/function.imagerectangle.php)— 畫一個矩形 * [imageresolution](https://www.php.net/manual/zh/function.imageresolution.php)— Get or set the resolution of the image * [imagerotate](https://www.php.net/manual/zh/function.imagerotate.php)— 用給定角度旋轉圖像 * [imagesavealpha](https://www.php.net/manual/zh/function.imagesavealpha.php)— 設置標記以在保存 PNG 圖像時保存完整的 alpha 通道信息(與單一透明色相反) * [imagescale](https://www.php.net/manual/zh/function.imagescale.php)— Scale an image using the given new width and height * [imagesetbrush](https://www.php.net/manual/zh/function.imagesetbrush.php)— 設定畫線用的畫筆圖像 * [imagesetclip](https://www.php.net/manual/zh/function.imagesetclip.php)— Set the clipping rectangle * [imagesetinterpolation](https://www.php.net/manual/zh/function.imagesetinterpolation.php)— Set the interpolation method * [imagesetpixel](https://www.php.net/manual/zh/function.imagesetpixel.php)— 畫一個單一像素 * [imagesetstyle](https://www.php.net/manual/zh/function.imagesetstyle.php)— 設定畫線的風格 * [imagesetthickness](https://www.php.net/manual/zh/function.imagesetthickness.php)— 設定畫線的寬度 * [imagesettile](https://www.php.net/manual/zh/function.imagesettile.php)— 設定用于填充的貼圖 * [imagestring](https://www.php.net/manual/zh/function.imagestring.php)— 水平地畫一行字符串 * [imagestringup](https://www.php.net/manual/zh/function.imagestringup.php)— 垂直地畫一行字符串 * [imagesx](https://www.php.net/manual/zh/function.imagesx.php)— 取得圖像寬度 * [imagesy](https://www.php.net/manual/zh/function.imagesy.php)— 取得圖像高度 * [imagetruecolortopalette](https://www.php.net/manual/zh/function.imagetruecolortopalette.php)— 將真彩色圖像轉換為調色板圖像 * [imagettfbbox](https://www.php.net/manual/zh/function.imagettfbbox.php)— 取得使用 TrueType 字體的文本的范圍 * [imagettftext](https://www.php.net/manual/zh/function.imagettftext.php)— 用 TrueType 字體向圖像寫入文本 * [imagetypes](https://www.php.net/manual/zh/function.imagetypes.php)— 返回當前 PHP 版本所支持的圖像類型 * [imagewbmp](https://www.php.net/manual/zh/function.imagewbmp.php)— 以 WBMP 格式將圖像輸出到瀏覽器或文件 * [imagewebp](https://www.php.net/manual/zh/function.imagewebp.php)— 將 WebP 格式的圖像輸出到瀏覽器或文件 * [imagexbm](https://www.php.net/manual/zh/function.imagexbm.php)— 將 XBM 圖像輸出到瀏覽器或文件 * [iptcembed](https://www.php.net/manual/zh/function.iptcembed.php)— 將二進制 IPTC 數據嵌入到一幅 JPEG 圖像中 * [iptcparse](https://www.php.net/manual/zh/function.iptcparse.php)— 將二進制 IPTC 塊解析為單個標記 * [jpeg2wbmp](https://www.php.net/manual/zh/function.jpeg2wbmp.php)— 將 JPEG 圖像文件轉換為 WBMP 圖像文件 * [png2wbmp](https://www.php.net/manual/zh/function.png2wbmp.php)— 將 PNG 圖像文件轉換為 WBMP 圖像文件 示例: ``` /** * 裁剪圖片 * @param $img 原圖路徑 'uploads/ty/20200408/11111.png'; * @param $is_show 是否直接展示 '1' * @param $save_path 結果圖保存路徑 'uploads/ty/20200408'; */ function doImg($img, $is_show=0, $save_path) { if ( !file_exists($img) ) die('圖片不存在'); //創建源圖的實例 返回的是一個資源 $src = imagecreatefromstring(file_get_contents($img)); // 獲取原圖尺寸 索引 0 包含圖像寬度的像素值,索引1包含圖像高度的像素值、 索引2是圖像類型的標記、索引3是文本字符串 $info = getimagesize($img); //var_dump($info); // 裁剪開區域的點的坐標 (這里我從最左側 高二分之一點位開始) $x = 150; $y = 0; // 裁剪區域的寬和高 (這里我保留原圖寬高原二分之一尺寸) $width = $info[0]/2; $height = $info[1]/2; // 最終保存成圖片的寬和高,和源要等比例,否則會變形 $new_img_with = 300; //最終高度=指定寬度*(原始圖片的寬高比),這樣圖片不會變形 $new_img_height = round($new_img_with * ($height / $width)); //將裁剪區域復制到新圖片上 // 新建一個真彩色圖像 $res_image = imagecreatetruecolor($new_img_with, $new_img_height); //重采樣拷貝部分圖像并調整大小,將一幅圖像中的一塊正方形區域拷貝到另一個圖像中,平滑地插入像素值,因此,尤其是,減小了圖像的大小而仍然保持了極大的清晰度 //這里是將$src中的部分圖像拷貝到新建的res_image圖片中 imagecopyresampled($res_image, $src, 0, 0, $x, $y, $new_img_with, $new_img_height, $width, $height); if ( $is_show == 1 ){ // 瀏覽器 輸出圖片 header('Content-Type: image/jpeg'); //輸出圖象到瀏覽器或文件 imagejpeg($res_image); imagedestroy($src); imagedestroy($res_image); }else{ // 保存圖片 $ext = pathinfo($img, PATHINFO_EXTENSION); $name = time().rand(1000, 9999); $path = $save_path . '/' . $name . '.' . $ext; //輸出圖象到瀏覽器或文件 imagejpeg($res_image, $path); imagedestroy($src); imagedestroy($res_image); die( '新圖片:'. $path ); } } ``` ![](https://img.kancloud.cn/7b/44/7b44a4f19414572e7029ce7708c5972c_481x458.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看