小编DaV*_*Da7的帖子

PHP调整大小图像给出黑色背景

我正在使用此代码调整大小:

  <?php
// Function for resizing any jpg, gif, or png image files
function ak_img_resize($target, $newcopy, $w, $h, $ext) {
    list($w_orig, $h_orig) = getimagesize($target);
    $scale_ratio = $w_orig / $h_orig;
    if (($w / $h) > $scale_ratio) {
           $w = $h * $scale_ratio;
    } else {
           $h = $w / $scale_ratio;
    }
    $img = "";
    $ext = strtolower($ext);
    if ($ext == "gif"){ 
      $img = imagecreatefromgif($target);
    } else if($ext =="png"){ 
      $img = imagecreatefrompng($target);
    } else { 
      $img = imagecreatefromjpeg($target);
    }
    $tci = imagecreatetruecolor($w, …
Run Code Online (Sandbox Code Playgroud)

php png transparency image-resizing

5
推荐指数
2
解决办法
7863
查看次数

标签 统计

image-resizing ×1

php ×1

png ×1

transparency ×1