Witam mam problem z generatorem zdjęć . Skrypt działa , ale tworzy brzydkie biała tło co na mojej stronie nie pasuje . Chciałbym aby skrypt tworzył przezroczyste tło , ale nie wiem jak . Próbowałem już użyć imagesavealpha() , ale coś mi nie działa
Oto kod generatora :
<?php
// Pobranie konfiguracji
include './config.php';
// Pobranie zawartości progress bara
include './data.php';
// Pobranie tablicy języka
include './lang_progress_bar.php';
// Sorotwanie
if($config['progress_bar']['sort_by'] === 0 || $config['progress_bar']['sort_by'] === 1 AND $config['progress_bar']['sort_type'] == 'asc' || $config['progress_bar']['sort_type'] == 'desc')
{
foreach($progress_bar as $key => $value)
{
$tmp['column'][$key] = $value[$config['progress_bar']['sort_by']];
}
array_multisort($tmp['column'], ($config['progress_bar']['sort_type'] == 'asc' ? SORT_ASC
: SORT_DESC
), $progress_bar); }
$tmp['how'] = count($progress_bar); // Tworzenie obrazka
$img = imagecreate($config['progress_bar']['width'], ($tmp['how'] == 0 ? 1 : $tmp['how']) * $config['progress_bar']['height']);
// Tworzenie kolorów
$tmp['color']['dark_red'] = imagecolorallocate($img, 200, 0, 0);
$tmp['color']['red'] = imagecolorallocate($img, 255, 0, 0);
$tmp['color']['orange'] = imagecolorallocate($img, 255, 200, 0);
$tmp['color']['green'] = imagecolorallocate($img, 169, 211, 41);
$tmp['color']['dark_green'] = imagecolorallocate($img, 128, 160, 32);
$tmp['color']['black'] = imagecolorallocate($img, 255, 255, 255);
$tmp['color']['white'] = imagecolorallocate($img, 255, 255, 255);
$tmp['color']['nic'] = imagecolorallocatealpha($img, 255, 255, 255, 100);
// Tło
imagefill($img, 0, 0, $tmp['color']['nic']);
// Rozmiary czcionek
$tmp['font']['width'] = imagefontwidth($config['progress_bar']['font_size']);
$tmp['font']['height'] = imagefontheight($config['progress_bar']['font_size']);
if($tmp['how'] > 0)
{
for($h = 0; $h < $tmp['how']; ++$h)
{
if(strlen($progress_bar[$h][0
]) > 27
) {
$progress_bar[$h][0
] = substr($progress_bar[$h][0], 0, 24).'...'; }
if(!is_int($progress_bar[$h][1
]) || $progress_bar[$h][1
] < 0
|| $progress_bar[$h][0
] > 100
) {
$progress_bar[$h][1] = 0;
}
// Pozycja procentów
if($config['progress_bar']['right_aligned_procent'] == true)
{
$tmp['procent_length'] = strlen($progress_bar[$h][1
]);
if($tmp['procent_length'] == 1)
{
$tmp['procent_position'] = 170 + 2 * $tmp['font']['width'];
}
else if($tmp['procent_length'] == 2)
{
$tmp['procent_position'] = 170 + $tmp['font']['width'];
}
else
{
$tmp['procent_position'] = 170;
}
}
else
{
$tmp['procent_position'] = 170;
}
// Obliczanie y1, y2
$tmp['y'][0] = 20 * $h;
$tmp['y'][1] = 20 * $h + $tmp['font']['height'];
// Nazwa projektu
imagestring($img, $config['progress_bar']['font_size'], 5, $h * 20 + 2, $progress_bar[$h][0], $tmp['color']['black']);
// Postęp
imagestring($img, $config['progress_bar']['font_size'], $tmp['procent_position'], $h * 20 + 2, $progress_bar[$h][1].'%', $tmp['color']['black']);
// Wybieranie koloru dla paska postępu
if($progress_bar[$h][1] > 85)
{
$tmp['color']['bar'] = $tmp['color']['dark_green'];
}
else if($progress_bar[$h][1] > 70)
{
$tmp['color']['bar'] = $tmp['color']['green'];
}
else if($progress_bar[$h][1] > 40)
{
$tmp['color']['bar'] = $tmp['color']['orange'];
}
else if($progress_bar[$h][1] > 10)
{
$tmp['color']['bar'] = $tmp['color']['red'];
}
else
{
$tmp['color']['bar'] = $tmp['color']['dark_red'];
}
// Pasek postępu
if($progress_bar[$h][1] > 0)
{
imagefilledrectangle
($img, 201
, $tmp['y'][0
] + 3
, 201
+ floor($progress_bar[$h][1
] * 2
.95
), $tmp['y'][1
], $tmp['color']['bar']); }
// Lewa kreska postępu
imagefilledrectangle($img, 200, $tmp['y'][0] + 3, 200, $tmp['y'][1], $tmp['color']['bar']);
// Prawa kreska postępu
imagefilledrectangle($img, 495, $tmp['y'][0] + 3, 496, $tmp['y'][1], $tmp['color']['bar']);
// Napisy na progress barze
if($config['progress_bar']['inscriptions_on_the_bar'] === true)
{
if($progress_bar[$h][1] == 100)
{
$tmp['inscription'] = $lang['progress_bar']['been_completed'];
}
else if($progress_bar[$h][1] > 95)
{
$tmp['inscription'] = $lang['progress_bar']['its_almost_done'];
}
else
{
$tmp['inscription'] = '';
}
imagestring($img, 2, 210, $tmp['y'][0] + 1, $tmp['inscription'], $tmp['color']['black']);
}
}
}
else
{
$tmp['font']['width'] *= strlen($lang['progress_bar']['we_currently_do_not_work_on_any_project']); $tmp['position']['center'] = ceil(($config['progress_bar']['width'] - $tmp['font']['width']) / 2
); $tmp['position']['middle'] = ceil(($config['progress_bar']['height'] - $tmp['font']['height']) / 2
) - 1; // Tworzenie wyśrodkowanego napisu mówiącego o braku projektów
imagestring($img, $config['progress_bar']['font_size'], $tmp['position']['center'], $tmp['position']['middle'], $lang['progress_bar']['we_currently_do_not_work_on_any_project'], $tmp['color']['black']);
}
header('Content-type: image/png'); # header('Expires: Mon, 26 Jul 1997 0500 GMT');
# header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
# header('Cache-Control: no-store, no-cache, must-revalidate');
# header('Cache-Control: post-check=0, pre-check=0', false);
# header('Pragma: no-cache');
imagepng($img);
imagedestroy($img);
?>
I postawie coś takiego :
nie jest to idealnie przezroczysta . Pozostaje taka biała otoczka , czy ktoś może mi pomóc