SHARE
TWEET

Immagini da cartella

Holy87 Dec 29th, 2014 (edited) 172 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     function genera_codice_immagini()
  3.     {
  4.         $files = glob("immagini/*.[jJ][pP][gG]");
  5.         foreach ($files as $image) {
  6.             echo '<a href="'.$image.'"> <img src="'.get_thumb(basename($image)).'" width="75" height="75" alt=""/></a>';
  7.         }
  8.     }
  9.        
  10.         function create_thumb($imagename)
  11.         {
  12.                 $thumbnail = imagecreatetruecolor(75, 75);
  13.                 $source = imagecreatefromjpeg("immagini/".$imagename);
  14.                 imagecopyresized($thumbnail, $source, 0, 0, 0, 0, 75, 75, imagesx($source), imagesy($source));
  15.                 header('Content-Type: image/jpeg');
  16.                 imagejpeg($thumbnail, "thumbnails/".$imagename);
  17.         }
  18.        
  19.         function get_thumb($imagename)
  20.         {
  21.                 if (file_exists("thumbnails/".$imagename))
  22.                 {
  23.                         /* niente */
  24.                 } else {
  25.                         create_thumb($imagename);
  26.                 }
  27.                 return "thumbnails/".$imagename;
  28.         }
  29.         genera_codice_immagini();
  30. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top