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 (1 - 4)
beton
post
Post #2





Grupa: Zarejestrowani
Postów: 13
Pomógł: 2
Dołączył: 5.11.2003
Skąd: Tarnowskie Góry

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


Hm, przechowywanie jedynie ID obrazków ... najlepiej odrazu człon nazwowy do tego rozszerzenie oraz numer id dla identyfikacji ktory to numer obrazka

funkcje pomocne: wszystkie z zakresu image* , jezeli chcesz tworzyc miniaturki lepiej poszukac gotowej biblioteki (jest chyba php thumbnailer), wiadomo zbieranie wyników z bazy danych przez mysql_query i mysql_fetch (aczkolwiek wole biblioteke ADODB) itd.


--------------------
Impossible is nothing.
php is for idiots, i'm using php version 5
Go to the top of the page
+Quote Post
bobens_83
post
Post #3





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
hondek
post
Post #4





Grupa: Zarejestrowani
Postów: 355
Pomógł: 50
Dołączył: 20.08.2007
Skąd: Częstochowa

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


Nie masz chyba biblioteki GD w PHP poprostu winksmiley.jpg


--------------------
przetwornik yt na czasie :)
Go to the top of the page
+Quote Post
bobens_83
post
Post #5





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

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


Tutaj czytam ze

Windows

The php_gd2.dll is included in a standard PHP installation for Windows, it's not enabled by default. You have to turn it on, the user may simply uncomment the line "extension=php_gd2.dll" in php.ini and restart the PHP extension.

Change:

#extension=php_gd2.dll

To:

extension=php_gd2.dll

You may also have to correct the extension directory setting from:

extension_dir = "./"

Or:

extension_dir = "./extensions"





w pliku php.ini odkomentowalem wiec ';extension=php_gd2.dll' -> 'extension=php_gd2.dll' . Poniewaz w pliku php.ini nie znalazlem slowa 'extension_dir' nie zrobilem z tym nic. zrestartowalem wszystkie uslugi i ciagle lipa sad.gif





phpinfo pokazuje ze wszystko jest ok:
gd
GD Support enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.1.9
T1Lib Support enabled
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled


Ten post edytował bobens_83 1.03.2008, 20:56:52
Go to the top of the page
+Quote Post

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 Aktualny czas: 20.08.2025 - 13:40