Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Tworzenie z poziomu php pliku png z transparencją
Avatarus
post
Post #1





Grupa: Zarejestrowani
Postów: 304
Pomógł: 0
Dołączył: 12.12.2006
Skąd: Pszów

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


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:
  1. function createthumbnail($filetype,$origfile, $thumbfile, $new_w, $new_h,$kompresja,$co='') {
  2. global $ustawienia;
  3. if ($filetype == 1) { $origimage = imagecreatefromgif($origfile); }
  4. elseif ($filetype == 2) { $origimage = imagecreatefromjpeg($origfile); }
  5. elseif ($filetype == 3) { $origimage = imagecreatefrompng($origfile); }
  6.  
  7. $old_x = imagesx($origimage);
  8. $old_y = imagesy($origimage);
  9. if ($ustawienia[galeria_inteli]=='OFF' or $co=1)
  10. {
  11. if ($old_x > $new_w || $old_y > $new_h) {
  12. if ($old_x < $old_y) {
  13. $thumb_w = round(($old_x * $new_h) / $old_y);
  14. $thumb_h = $new_h;
  15. } elseif ($old_x > $old_y) {
  16. $thumb_w = $new_w;
  17. $thumb_h = round(($old_y * $new_w) / $old_x);
  18. } else {
  19. $thumb_w = $new_w;
  20. $thumb_h = $new_h;
  21. }
  22. } else {
  23. $thumb_w = $old_x;
  24. $thumb_h = $old_y;
  25. }
  26. }
  27. else
  28. {
  29. $thumb_w = $new_w;
  30. $thumb_h = $new_h;
  31. }
  32. if ($kompresja == "gd1") {
  33. $thumbimage = imagecreate($thumb_w,$thumb_h);
  34. $result = imagecopyresized($thumbimage, $origimage, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
  35. } else {
  36. $thumbimage = imagecreatetruecolor($thumb_w,$thumb_h);
  37. $result = imagecopyresampled($thumbimage, $origimage, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
  38. }
  39.  
  40. touch($thumbfile);
  41.  
  42. if ($filetype == 1)
  43. {
  44. imagegif($thumbimage, $thumbfile);
  45. }
  46. elseif ($filetype == 2)
  47. {
  48. imagejpeg($thumbimage, $thumbfile);
  49. }
  50. elseif ($filetype == 3)
  51. {
  52. imagepng($thumbimage, $thumbfile);
  53. }
  54. }
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 27.09.2025 - 13:55