Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php]Pomniejszone zdjecie
Spyder
post
Post #1





Grupa: Zarejestrowani
Postów: 269
Pomógł: 7
Dołączył: 12.10.2006
Skąd: Newcastle Upon Tyne

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


Prosze o pomoc z tym kodem:

  1. <?php
  2. $nazwa = "Creek.jpg";
  3. $galeria = "news_pictures";
  4. $out = $galeria . "/tn" . $nazwa;
  5. $file = "news_pictures/Creek.jpg";
  6. $max_width = 300;
  7. $max_height = 100;
  8. $size = GetImageSize($file);
  9. $width = $size[0];
  10. $height = $size[1];
  11. $x_ratio = $max_width / $width;
  12. $y_ratio = $max_height / $height;
  13.  
  14. if (($width <= $max_width) && ($height <= $max_height)) {
  15.  $tn_width = $width;
  16.  $tn_height = $height;
  17. } else 
  18.  if (($x_ratio * $height) < $max_height) {
  19. $tn_height = ceil($x_ratio * $height);
  20. $tn_width = $max_width;
  21.  } else {
  22. $tn_width = ceil($y_ratio * $width);
  23. $tn_height = $max_height;
  24. }
  25.  
  26. $src = ImageCreateFromJpeg($file);
  27. $dst = ImageCreateTrueColor($tn_width,$tn_height);
  28.  
  29. ImageCopyResampled($dst, $src, 0, 0, 0, 0, $tn_width,$tn_height,$width,$height);
  30.  
  31. ImageJpeg($dst, $out, 85);
  32. ImageDestroy($src);
  33. ImageDestroy($dst);
  34. chmod($galeria . "/tn" . $nazwa, 0777);
  35. ?>


Chodzi o to ze mam zdjecie na serwerze w katalogu news_pictures rozdzialka zdjecia powiedzmy 800 x 600 chodzi o to aby funkcja pobrala wielkosc zdjecia i wyswietlila pomniejszona miniaturke o max szerokosci 120 pikseli nie musi jej zapisywac na serwerze tylko wyswietlic pomniejszona w stosunku a to nie chce zadzialac questionmark.gif Czytalem inne skrypty na forum ale nie wiem jak to zrobic najprosciej.....


--------------------
Portfolio

Windows Vista Business SP1
DELL VOSTRO 200, Intel Core2 DUO E4600 2.4GHz, 3 GB RAM, ATI Radeon HD 2400 Pro, Screen DELL 22"

Pomogłem ci -> Kliknij "Pomógł" -> Dzięki
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
szawel
post
Post #2





Grupa: Zarejestrowani
Postów: 59
Pomógł: 1
Dołączył: 7.06.2007
Skąd: torun

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


moze skaorzystasz z funkcji exif_thumbnail(nazwa pliku,szerokosc,wysokosc,opcjonalnie typ);
$file='costam.jpg';
exif_thumbnail($file,$width,$height,$type);
Go to the top of the page
+Quote Post
Spyder
post
Post #3





Grupa: Zarejestrowani
Postów: 269
Pomógł: 7
Dołączył: 12.10.2006
Skąd: Newcastle Upon Tyne

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


tak ale zachowa ona proporcje jesli zdjecie bedzie np 800x800 questionmark.gif


--------------------
Portfolio

Windows Vista Business SP1
DELL VOSTRO 200, Intel Core2 DUO E4600 2.4GHz, 3 GB RAM, ATI Radeon HD 2400 Pro, Screen DELL 22"

Pomogłem ci -> Kliknij "Pomógł" -> Dzięki
Go to the top of the page
+Quote Post
szawel
post
Post #4





Grupa: Zarejestrowani
Postów: 59
Pomógł: 1
Dołączył: 7.06.2007
Skąd: torun

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


z tego co wiem to powino bo to pobiera miniaturke z pliku jpg jesli jest zdefiniowana jakos tak to dziala...
Go to the top of the page
+Quote Post
Spyder
post
Post #5





Grupa: Zarejestrowani
Postów: 269
Pomógł: 7
Dołączył: 12.10.2006
Skąd: Newcastle Upon Tyne

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


Chyba cos nie dziala...

  1. <?php
  2. #
  3. $file = 'test.jpg';
  4. #
  5.  
  6. #
  7. $image = exif_thumbnail($file, $width, $height, $type);
  8. #
  9.  
  10. #
  11. // width, height and type get filled with data
  12. #
  13. // after calling "exif_thumbnail"
  14. #
  15.  
  16. #
  17. if ($image) {
  18. #
  19. // send header and image data to the browser:
  20. #
  21. header('Content-type: ' .image_type_to_mime_type($type));
  22. #
  23. print $image;
  24. #
  25. }
  26. #
  27. else {
  28. #
  29. // there is no thumbnail available, handle the error:
  30. #
  31. print 'No thumbnail available';
  32. #
  33. }
  34. ?>


--------------------
Portfolio

Windows Vista Business SP1
DELL VOSTRO 200, Intel Core2 DUO E4600 2.4GHz, 3 GB RAM, ATI Radeon HD 2400 Pro, Screen DELL 22"

Pomogłem ci -> Kliknij "Pomógł" -> Dzięki
Go to the top of the page
+Quote Post
szawel
post
Post #6





Grupa: Zarejestrowani
Postów: 59
Pomógł: 1
Dołączył: 7.06.2007
Skąd: torun

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


exif_thumbnail($file) tylko ma byc $width i $height $type sa zwracane przez funkcje sory za to ze cie wprowadzilem w blad
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: 22.08.2025 - 05:33