Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa tarde,
Estou com problemas para manipular imagem png transparente. A imagem só sobe com fundo preto. Se puderem olhar, por favor:
public function saveImg($filename) {
list( $largura, $altura ) = getimagesize($filename);
if ($largura > $this->max_img_width || $altura > $this->max_img_height) {
return $this->ResizeImg($filename);
}
$novo_nome = $this->path . $this->randName($filename);
move_uploaded_file($filename, $novo_nome);
return $novo_nome;
}
protected function ResizeImg($filename) {
list( $largura, $altura ) = getimagesize($filename);
$img_type = $this->getImgType($filename);
if ($largura > $altura) {
$nova_largura = $this->max_img_width;
$nova_altura = round(($nova_largura / $largura) * $altura);
} elseif ($altura > $largura) {
$nova_altura = $this->max_img_height;
$nova_largura = round(($nova_altura / $altura) * $largura);
} else {
$nova_altura = $nova_largura = $this->max_img_width;
}
$src_img = call_user_func('imagecreatefrom' . $img_type, $filename);
$dst_img = imagecreatetruecolor($nova_largura, $nova_altura);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nova_largura, $nova_altura, $largura, $altura);
$nome_img = $this->path . $this->randName($filename);
if ($img_type == 'jpeg') {
imagejpeg($dst_img, $nome_img, $this->img_quality);
} else {
call_user_func('image' . $img_type, $dst_img, $nome_img);
}
imagedestroy($src_img);
imagedestroy($dst_img);
return $nome_img;
}
Obrigado pela atenção.
Carregando comentários...