Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Problem z miniaturkami ( czarne miniaturki )
deadwheel
post 22.06.2013, 20:43:51
Post #1





Grupa: Zarejestrowani
Postów: 26
Pomógł: 2
Dołączył: 8.11.2011

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


Jak w temacie mam problem z tworzeniem miniaturek . Tworzy tylko czarne obrazki .

  1. function savethumb($image,$dest) {
  2.  
  3. global $new_chmod;
  4.  
  5. $maxheight = 91;
  6. $maxwidth = 135;
  7.  
  8. $ext=getimagesize($image);
  9. switch (strtolower($ext[2])) {
  10. case '2': $im = imagecreatefromjpeg ($image);
  11. break;
  12. case '1' : $im = imagecreatefromgif ($image);
  13. break;
  14. case '3' : $im = imagecreatefrompng ($image);
  15. break;
  16. default : $stop = true;
  17. break;
  18. }
  19.  
  20. $result="";
  21. if (!isset($stop)) {
  22. $x = imagesx($im);
  23. $y = imagesy($im);
  24.  
  25.  
  26.  
  27. if ($y > $x)
  28. {
  29. $ratio = $maxheight / $aa;
  30. $newheight = $maxheight;
  31. $newwidth = $x * $ratio;
  32. $writex = round(($maxwidth - $newwidth) / 2);
  33. $writey = 0;
  34. }
  35. else
  36. {
  37. $ratio = $maxwidth / $x;
  38. $newwidth = $maxwidth;
  39. $newheight = $y * $ratio;
  40. $writex = 0;
  41. $writey = round(($maxheight - $newheight) / 2);
  42. }
  43.  
  44. $newimg = imagecreatetruecolor($maxwidth,$maxheight);
  45.  
  46.  
  47. $palsize = ImageColorsTotal($im); //Get palette size for original image
  48. for ($i = 0; $i < $palsize; $i++) //Assign color palette to new image
  49. {
  50. $colors = ImageColorsForIndex($im, $i);
  51. ImageColorAllocate($newimg, $colors['red'], $colors['green'], $colors['blue']);
  52. }
  53.  
  54. imagecopyresized($newimg, $im, $writex, $writey, 0, 0, $newwidth, $newheight, $x, $y);
  55. imagejpeg($newimg, $dest, 80);
  56. @chmod($dest, $new_chmod);
  57.  
  58. imagedestroy($im);
  59. imagedestroy($newimg);
  60. return $result;
  61. } else return false;
  62. }


Mysle ze poprostu zapisuje on $newimg czyli poprostu czarny obrazek bo nie jest on wypelniany ale nie mam pojecia jak go wypelnic wiec licze na wasza pomoc
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: 14.08.2025 - 00:18