Witam
Mam problem z transparencją pliku png.
Mam plik png ma transparencje na kolor czarny.
Plik jest pobierany z pliku na komputerze i później zmniejszany do odpowiednich rozmiarów.
do tego momentu działa dobrze, ale nie zachowuje transparencji.
Jak to poprawić?
moja funkcja to tworzenia miniatur wygląda tak:
function createthumbnail($filetype,$origfile, $thumbfile, $new_w, $new_h,$kompresja,$co='') {
if ($filetype == 1) { $origimage = imagecreatefromgif($origfile); }
elseif ($filetype == 2) { $origimage = imagecreatefromjpeg($origfile); }
elseif ($filetype == 3) { $origimage = imagecreatefrompng($origfile); }
$old_x = imagesx($origimage);
$old_y = imagesy($origimage);
if ($ustawienia[galeria_inteli]=='OFF' or $co=1)
{
if ($old_x > $new_w || $old_y > $new_h) {
if ($old_x < $old_y) {
$thumb_w = round(($old_x * $new_h) / $old_y); $thumb_h = $new_h;
} elseif ($old_x > $old_y) {
$thumb_w = $new_w;
$thumb_h = round(($old_y * $new_w) / $old_x); } else {
$thumb_w = $new_w;
$thumb_h = $new_h;
}
} else {
$thumb_w = $old_x;
$thumb_h = $old_y;
}
}
else
{
$thumb_w = $new_w;
$thumb_h = $new_h;
}
if ($kompresja == "gd1") {
$thumbimage = imagecreate($thumb_w,$thumb_h);
$result = imagecopyresized($thumbimage, $origimage, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
} else {
$thumbimage = imagecreatetruecolor($thumb_w,$thumb_h);
$result = imagecopyresampled($thumbimage, $origimage, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
}
if ($filetype == 1)
{
imagegif($thumbimage, $thumbfile);
}
elseif ($filetype == 2)
{
imagejpeg($thumbimage, $thumbfile);
}
elseif ($filetype == 3)
{
imagepng($thumbimage, $thumbfile);
}
}