- Home
- Categorie
- Coding e Sistemistica
- Coding
- Resize di un'immagine: sfondo non uniforme
-
Resize di un'immagine: sfondo non uniforme
Salve a tutti,
sto cercando di effettuare il resize di un'immagine, ma ho il problema che lo sfondo dell'immagine non risulta completamente bianco, ma ha delle righe orizzontali di grigio chiaro.Questo il codice che utilizzo per il resize:
function resize_image($img, $imagedata, $new_w, $new_h) { global $use_truecolor, $use_resampling, $r, $g, $b; // Create a new, empty image based on settings: if (function_exists('imagecreatetruecolor') && $use_truecolor && ($imagedata[2] == 2 || $imagedata[2] == 3)) { $tmp_img = imagecreatetruecolor($new_w, $new_h); } else { $tmp_img = imagecreate($new_w, $new_h); } $th_bg_color = imagecolorallocate($tmp_img, $r, $g, $b); imagefill($tmp_img, 0, 0, $th_bg_color); //imagecolortransparent($tmp_img, $th_bg_color); // Create the image to be scaled: if ($imagedata[2] == 2 && function_exists('imagecreatefromjpeg')) { $src = imagecreatefromjpeg($img); } elseif ($imagedata[2] == 1 && function_exists('imagecreatefromgif')) { $src = imagecreatefromgif($img); } elseif (($imagedata[2] == 3 || $imagedata[2] == 1) && function_exists('imagecreatefrompng')) { $src = imagecreatefrompng($img); } else { return false; } // Scale the image based on settings: if (function_exists('imagecopyresampled') && $use_resampling) { imagecopyresampled($tmp_img, $src, 0, 0, 0, 0, $new_w, $new_h, $imagedata[0], $imagedata[1]); } else { imagecopyresized($tmp_img, $src, 0, 0, 0, 0, $new_w, $new_h, $imagedata[0], $imagedata[1]); } return $tmp_img; }
Sapete spiegarmi perchè ho questo problema?
Grazie