Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Closed TopicStart new topic
> [PHP] Wyświetalnie tylko .jpg, Wyświetam pliki z katalogu.
Immanuel
post
Post #1





Grupa: Zarejestrowani
Postów: 84
Pomógł: 0
Dołączył: 9.09.2005
Skąd: Lubin

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


Witam,

Jak zrobić, że wyświetlało tylko .jpg ?

  1. <?php
  2.  
  3. if ($handle = opendir('obrazy')) {
  4.  
  5. /* To jest poprawna metoda */
  6. while (false !== ($file = readdir($handle))) { 
  7. echo "<img src=obrazy$file\n<br>";
  8. }
  9.  closedir($handle); 
  10. }
  11. ?>


I jak dynamicznie stworzyc miniatury ?
Podpowiedzcie chociaz nazwe funkcji (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
marcio
post
Post #2





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

Ostrzeżenie: (10%)
X----


Funkcja skalujaca:
  1. <?php
  2. function skaluj($imageFile, $type, $maxImageWidth, $maxImageHeight, $newImageName, $imageQuality) {
  3.  
  4. if($type == 'image/jpg' || $type == 'image/jpeg') $imageData = imagecreatefromjpeg($imageFile);
  5. else if($type == 'image/gif') $imageData = imagecreatefromgif($imageFile);
  6. else if($type == 'image/png') $imageData = imagecreatefrompng($imageFile);
  7.  
  8. //$imageData = imagecreatefromjpeg($imageFile);
  9. list($imageWidth, $imageHeight) = getimagesize($imageFile);
  10. $imageRatioWidth = $imageWidth > $maxImageWidth ? $maxImageWidth / $imageWidth : 1;
  11. $imageRatioHeight = $imageHeight * $imageRatioWidth > $maxImageHeight ? $maxInameHeight / $imageHeight : 1;
  12. $newImageSizeWidth = floor($imageWidth * $imageRatioWidth * $imageRatioHeight);
  13. $newImageSizeHeight = floor($imageHeight * $imageRatioWidth * $imageRatioHeight);
  14. $newImage = imagecreatetruecolor($newImageSizeWidth, $newImageSizeHeight);
  15. imagecopyresampled($newImage, $imageData, 0, 0, 0, 0, $newImageSizeWidth, $newImageSizeHeight, $imageWidth, $imageHeight);
  16. $savePath = $newImageName;
  17. imagejpeg($newImage, $savePath, $imageQuality);
  18. //imagedestroy($imageData); 
  19. }
  20. ?>


A co do jpg to rozbijaj nazwy plikow i sprawdzaj lub zapisuj tylko jpg
Go to the top of the page
+Quote Post
Ociu
post
Post #3





Grupa: Moderatorzy
Postów: 1 566
Pomógł: 37
Dołączył: 14.05.2003
Skąd: Kraków




substr" title="Zobacz w manualu PHP" target="_manual, getimagesize" title="Zobacz w manualu PHP" target="_manual i wiele wyników w google, którego pewnie nawet nie chciało Ci się otworzyć.
Zamykam.
Go to the top of the page
+Quote Post

Closed TopicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 23:43