<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 圖片縮略實現 ## 指定長寬縮略 指定長、寬實現圖片的縮略效果,縮略圖尺寸模仿京東圖片的尺寸。 ``` <?php $filename = './images/jd.jpg'; $file_info = getimagesize($filename); if ($file_info) { list($width, $height) = $file_info; } else { die("文件不是真實圖片"); } $src_image = imagecreatefromjpeg($filename); $dst_image_50 = imagecreatetruecolor(50, 50); $dst_image_270 = imagecreatetruecolor(270, 270); imagecopyresampled($dst_image_50, $src_image, 0, 0, 0, 0, 50, 50, $width, $height); imagecopyresampled($dst_image_270,$src_image,0,0,0,0,270,270,$width,$height); imagejpeg($dst_image_50,'./images/jd_50x50.jpg'); imagejpeg($dst_image_270,'./images/jd_270x270.jpg'); imagedestroy($dst_image_50); imagedestroy($dst_image_270); imagedestroy($src_image); ``` ## 等比例縮放 指定縮放比例,最大寬度和高度,等比例縮放,可以對縮略圖文件添加前綴,選擇是否刪除縮略圖源文件 ``` <?php /** * @param string $file_name 文件名 * @param string $dst_path 縮略圖保存路徑 * @param string $prefix 縮略圖保存的前綴 * @param null $dst_w 目標的最大寬度 * @param null $dst_h 目標的最大高度 * @param float $scale 縮放比例 * @param bool $delete_source 是否刪除源文件的標志 */ function thumb($file_name, $dst_path = 'thumb', $prefix = 'thumb_', $dst_w = null, $dst_h = null, $scale = 0.5, $delete_source = false) { $file_info = getImageInfo($file_name); $src_w = $file_info['width']; $src_h = $file_info['height']; // 如果指定最大寬度和高度按照等比例縮放進行處理 if (is_numeric($dst_w) && is_numeric($dst_h)) { $ratio_orig = $src_w / $src_h; if ($dst_w / $dst_h > $ratio_orig) { $dst_w = $dst_h * $ratio_orig; } else { $dst_h = $dst_w / $ratio_orig; } } else { $dst_w = ceil($src_w * $scale); $dst_h = ceil($src_h * $scale); } $dst_image = imagecreatetruecolor($dst_w, $dst_h); $src_image = $file_info['create_fun']($file_name); imagecopyresampled($dst_image, $src_image, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h); // 檢測目標目錄是否存在 if ($dst_path && !file_exists($dst_path)) { mkdir($dst_path, 0777, true); } $dst_name = "{$prefix}{$file_info['file_name']}" . $file_info['extension']; $destination = $dst_path ? $dst_path . '/' . $dst_name : $dst_name; // 保存的文件名 $file_info['out_fun']($dst_image, $destination); if ($delete_source) { @unlink($file_name); } imagedestroy($src_image); imagedestroy($dst_image); } /** * @param $filename string 文件名 * @return array */ function getImageInfo($filename) { if (!$info = getimagesize($filename)) { exit('文件不是真實圖片!'); } $file_info['file_name'] = pathinfo($filename)['filename']; $file_info['width'] = $info[0]; $file_info['height'] = $info[1]; $mime = image_type_to_mime_type($info[2]); $file_info['extension'] = image_type_to_extension($info[2], true); $file_info['create_fun'] = str_replace('/', 'createfrom', $mime); $file_info['out_fun'] = str_replace('/', '', $mime); return $file_info; } ```
                  <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>

                              哎呀哎呀视频在线观看