Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]imagecreatetruecolor - czarne tło
stroju
post 10.01.2009, 19:37:56
Post #1





Grupa: Zarejestrowani
Postów: 179
Pomógł: 2
Dołączył: 17.11.2005

Ostrzeżenie: (0%)
-----


mam taką funkcję:
  1. <?php
  2. switch($typ_pliku)
  3.     {
  4.          case 'image/jpeg':
  5.          $pref_gd = "jpeg";
  6.          break;
  7.          case 'image/png':
  8.          $pref_gd = "png";
  9.          break;
  10.          case 'image/pjpeg':
  11.          $pref_gd = "jpg";
  12.          break;
  13.          case 'image/gif':
  14.          $pref_gd = "gif";
  15.          break;
  16.     }
  17.    
  18.  
  19.    
  20. $size = @getimagesize($file);
  21. $width = $size[0];
  22. $height = $size[1];
  23. $x_ratio = $max_width / $width;
  24. $y_ratio = $max_height / $height;
  25. if(($width <= $max_width) && ($height <= $max_height))
  26. {
  27.   $tn_width = $width;
  28.   $tn_height = $height;
  29. }
  30. else if(($x_ratio * $height) < $max_height)
  31. {
  32.   $tn_height = ceil($x_ratio * $height);
  33.   $tn_width = $max_width;
  34. }
  35. else
  36. {
  37.   $tn_width = ceil($y_ratio * $width);
  38.   $tn_height = $max_height;
  39. }
  40.  
  41. $func_plus_prefix_1 = "imagecreatefrom".$pref_gd;
  42. $func_plus_prefix_2 = "image".$pref_gd;
  43.  
  44. $src = @$func_plus_prefix_1($file);
  45. $dst = imagecreatetruecolor($tn_width, $tn_height);
  46. @imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height);
  47.  
  48. if($typ_pliku == 'image/png')
  49. {
  50.    if(@imagepng($dst, $katalog.'/'.$name))
  51.    return true;
  52. }
  53. else
  54. {
  55.    if(@$func_plus_prefix_2($dst, $katalog.'/'.$name, $jakosc))
  56.    return true;
  57. }
  58. ?>


i mój problem polega na tym że pliki png mają czarne tło jak są przeźroczyste, a wiem ze powinno być przeźroczyste albo białe
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 16.07.2025 - 08:38