Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Zmniejszenie animowanego GIFa
deha21
post 5.03.2015, 21:14:55
Post #1





Grupa: Zarejestrowani
Postów: 544
Pomógł: 5
Dołączył: 18.08.2009

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


Potrzebuję zmniejszyć rozmiar(rozdzielczość) animowanego GIFa. Mam taki kod jak poniżej. Wszysko się pomniejsza i dodaje watermark, ale jest stopklatka a chciałbym, żeby GIF pozostał animowany. Czytałem w necie o różnych bibliotekach, które to umożliwiają. Niestety nie mogą żadnej dodać. Czy jest możliwość zrobić to jakoś bez bibliotek?
(ten kawałek który wykomentował jest chyba nie potrzebny, bo bez tego działa tak jak działało; znalazłem w necie i myślałem, że pomoże przy GIFie ale nie)
  1. function watermark($filef, $new_width, $new_height, $quality) {
  2.  
  3. $info = getimagesize($filef);
  4. if ($info === false) { return false; }
  5. $img = imagecreatefromgif($filef);
  6.  
  7. $th = imagecreatetruecolor($new_width, $new_height+25);
  8. $watermark = imagecreatefrompng('watermark.png');
  9.  
  10. /*
  11. imagealphablending($th, false);
  12. imagesavealpha($th,true);
  13. $transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);
  14. imagefilledrectangle($th, 0, 0, $new_width, $new_height, $transparent);
  15. */
  16.  
  17. imagecopyresampled($th, $img, 0, 0, 0, 0, $new_width, $new_height, $info[0], $info[1]);
  18. imagecopy($th, $watermark, $new_width-142, $new_height, 0, 0, 142, 25);
  19. imagegif($th, $filef, $quality);
  20.  
  21. imagedestroy($th);
  22. imagedestroy($img);
  23. return true;
  24.  
  25. }


Ten post edytował deha21 5.03.2015, 21:16:39


--------------------
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: 3.07.2025 - 01:49