Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Miniatura obrazka, a potem wyswietlenie jego
NetJaro
post
Post #1





Grupa: Zarejestrowani
Postów: 475
Pomógł: 0
Dołączył: 1.04.2005
Skąd: Warszawa

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


Jak zrobić miniaturę obrazka a potem po kliknięciu na tą miniature pojawił się oryginalny rozmiar obrazka w popupie?

Pozdro :-)

P.S

Mam kod co tworzy miniaturę obrazka:

  1. <?php
  2. header('Content-type: image/jpeg');
  3.  
  4. $myimage = resizeImage(&#092;"./img/$id.jpg\", \"200\", \"200\");
  5. function resizeImage($filename, $newwidth, $newheight){
  6. list($width, $height) = getimagesize($filename);
  7. if($width > $height && $newheight < $height){
  8. $newheight = $height / ($width / $newwidth);
  9. } else if ($width < $height && $newwidth < $width) {
  10. $newwidth = $width / ($height / $newheight);
  11. } else {
  12. $newwidth = $width;
  13. $newheight = $height;
  14. }
  15. $thumb = imagecreatetruecolor($newwidth, $newheight);
  16. $source = imagecreatefromjpeg($filename);
  17. imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
  18. return imagejpeg($thumb);
  19. }
  20. ?>


Lecz on wyświetla obrazek sam (tak jak działa <img>).

Ten post edytował NetJaro 7.05.2005, 20:42:39
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
NetJaro
post
Post #2





Grupa: Zarejestrowani
Postów: 475
Pomógł: 0
Dołączył: 1.04.2005
Skąd: Warszawa

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


  1. <?php
  2. if ($roz_pliku == &#092;"gif\"){
  3. header('Content-type: image/gif');
  4. $polecenie = &#092;"ImageCreateFromgif($filename);\";
  5. $polecenie2 = &#092;"imagegif($thumb)\";
  6. } elseif ($roz_pliku == &#092;"GIF\") {
  7. header('Content-type: image/gif');
  8. $polecenie2 = &#092;"imagegif($thumb)\";
  9. $polecenie = &#092;"ImageCreateFromgif($filename);\";
  10. } elseif ($roz_pliku == &#092;"jpg\") {
  11. header('Content-type: image/jpeg');
  12. $polecenie = &#092;"ImageCreateFromjpg($filename);\";
  13. $polecenie2 = &#092;"imagejpeg($thumb)\";
  14. } elseif ($roz_pliku == &#092;"JPG\") {
  15. header('Content-type: image/jpeg');
  16. $polecenie = &#092;"ImageCreateFromjpg($filename);\";
  17. $polecenie2 = &#092;"imagejpeg($thumb)\";
  18. } elseif ($roz_pliku == &#092;"PNG\") {
  19. header('Content-type: image/png');
  20. $polecenie = &#092;"ImageCreateFrompng($filename);\";
  21. $polecenie2 = &#092;"imagepng($thumb)\";
  22. } elseif ($roz_pliku == &#092;"png\") {
  23. header('Content-type: image/png');
  24. $polecenie = &#092;"ImageCreateFrompng($filename);\";
  25. $polecenie2 = &#092;"imagepng\";
  26. }
  27. $myimage = resizeImage(&#092;"./img/$id.$roz_pliku\", \"200\", \"200\");
  28. function resizeImage($filename, $newwidth, $newheight){
  29. list($width, $height) = getimagesize($filename);
  30. if($width > $height && $newheight < $height){
  31. $newheight = $height / ($width / $newwidth);
  32. } else if ($width < $height && $newwidth < $width) {
  33. $newwidth = $width / ($height / $newheight);
  34. } else {
  35. $newwidth = $width;
  36. $newheight = $height;
  37. }
  38. $thumb = imagecreatetruecolor($newwidth, $newheight);
  39. $source = $polecenie;
  40. imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
  41.  
  42. return $polecenie2;
  43. }
  44. ?>


Pojawia mi się:
Kod
<br />
<b>Warning</b>:  imagecopyresized(): supplied argument is not a valid Image resource in <b>/home/upload/domains/upload.multihost.us/public_html/show.php</b> on line <b>40</b><br />


Co jest źle z tą funckją?
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: 9.10.2025 - 20:22