Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Kompresja obrazka przed wyswietleniem na stronie, ... zeby stronka sie szybciej ladowala
bobens_83
post
Post #1





Grupa: Zarejestrowani
Postów: 112
Pomógł: 0
Dołączył: 7.11.2005
Skąd: z Czelsy

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


Witam. Mam pytanko, czy mozliwe jest aby przechowywac obrazki w katalogu na serwerze a w bazie jedynie ich ID. Nastepnie na stronie glownej (cos jak system news) wyswietlaja sie w petli obrazki, np 10 sztuk (skompresowane miniaturki obrazkow z katalogu). po kliknieciu na obrazek ten sie powieksza i pokazuje w oryginalnej rozdzielczosci. Jestli ma to sens to jakie funkcje PHP moga byc pomocne ? Pozdrawiam.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
bobens_83
post
Post #2





Grupa: Zarejestrowani
Postów: 112
Pomógł: 0
Dołączył: 7.11.2005
Skąd: z Czelsy

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


  1. <?php
  2. resizeToFile("graphics/test01.jpg", 100, 70, "graphics/test02.jpg", 75);
  3.  
  4. /* resizeToFile resizes a picture and writes it to the harddisk
  5.  * 
  6.  * $sourcefile = the filename of the picture that is going to be resized
  7.  * $dest_x  = X-Size of the target picture in pixels
  8.  * $dest_y  = Y-Size of the target picture in pixels
  9.  * $targetfile = The name under which the resized picture will be stored
  10.  * $jpegqual  = The Compression-Rate that is to be used
  11.  */
  12. function resizeToFile ($sourcefile, $dest_x, $dest_y, $targetfile, $jpegqual) {
  13. /* Get the dimensions of the source picture */
  14. $picsize=getimagesize("$sourcefile");
  15.  
  16. $source_x = $picsize[0];
  17. $source_y = $picsize[1];
  18. $source_id = imagecreatefromjpeg("$sourcefile");
  19.  
  20. /* Create a new image object (not neccessarily true colour) */
  21. $target_id=imagecreatetruecolor($dest_x, $dest_y);
  22.  
  23. /* Resize the original picture and copy it into the just created image
  24.    object. Because of the lack of space I had to wrap the parameters to
  25.    several lines. I recommend putting them in one line in order keep your
  26.    code clean and readable */
  27. $target_pic=imagecopyresampled($target_id,$source_id,
  28.  0,0,0,0,
  29.  $dest_x,$dest_y,
  30.  $source_x,$source_y);
  31.  
  32. /* Create a jpeg with the quality of "$jpegqual" out of the
  33.    image object "$target_pic".
  34.    This will be saved as $targetfile */
  35. imagejpeg ($target_id,"$targetfile",$jpegqual);
  36. return true;
  37. }
  38. ?>



zwraca:

Fatal error: Call to undefined function imagecreatefromjpeg()

Po wykomentowaniu tej linii wywala sie na kolejnej funkcji image*. Co moze byc przyczyna? Czy musze jeszcze cos zainkludowac?

Ten post edytował bobens_83 1.03.2008, 18:25:44
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: 2.10.2025 - 23:26