Foros del Web » Creando para Internet » Sistemas de gestión de contenidos »

¿Galería que se genere con todas las imágenes de un directorio?

Estas en el tema de ¿Galería que se genere con todas las imágenes de un directorio? en el foro de Sistemas de gestión de contenidos en Foros del Web. Hola ¿sabeis de alguna aplicación que genere automáticamente una página con thumbnails de todas las imágenes que hay en un directorio? Muchas Gracias....
  #1 (permalink)  
Antiguo 15/07/2006, 04:36
 
Fecha de Ingreso: junio-2003
Mensajes: 940
Antigüedad: 20 años, 10 meses
Puntos: 8
¿Galería que se genere con todas las imágenes de un directorio?

Hola

¿sabeis de alguna aplicación que genere automáticamente una página con thumbnails de todas las imágenes que hay en un directorio?

Muchas Gracias.
  #2 (permalink)  
Antiguo 16/07/2006, 00:21
 
Fecha de Ingreso: enero-2003
Mensajes: 274
Antigüedad: 21 años, 3 meses
Puntos: 1
si buscas una galeria de imagenes, proba con minigal buscala asi en google...
saludos
  #3 (permalink)  
Antiguo 17/07/2006, 19:42
Avatar de El_MiMo  
Fecha de Ingreso: septiembre-2003
Ubicación: Chile
Mensajes: 123
Antigüedad: 20 años, 7 meses
Puntos: 1
De acuerdo galeria

Estimado, mira www.autodromopacificosport.cl/?modulo=fotos.php

Este código toma las fotos de un directorio y general los th y la galería.

Código:
<?php // charset=ISO-8859-1
/*
 * galerie.php - a simple gallery script
 * Copyright (C) 2002, 2003  Daniel Wacker <[email protected]>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * --
 * This script provides a simple gallery of all images that are located
 * in the script's directory and subdirectories.
 *
 * Requirements
 * - PHP >= 4.1.0
 * - GD Library ( >= 2.0.1 for good thumbnails)
 * - JPEG software
 * - PHP >= 4.3.0 or GD < 1.6 for GIF support
 * - libpng for PNG support
 *
 * Installation
 * Simply put this script in a folder of your web server and call it in a
 * web browser. Be sure that the script has permission to read the image
 * files and to create and write into the thumbnail folder.
 *
 * Attention:
 * This script tries to generate jpeg thumbnail files in a subfolder of the
 * gallery folder(s). The filenames look like "originalfilename.thumb.jpg".
 *
/* ------------------------------------------------------------------------- */

/* Select your language:
 * 'en' - English
 * 'de' - German
 */
$lang = 'en';

/* Select your charset
 */
$charset = 'ISO-8859-1';

/* How many images per page?
 */
$maxpics = 28;

/* Create thumbnails in this subfolder
 */
$thumbdir = 'thumbs';

/* Size of created thumbnails
 */
$thumbsize = 120;

/* Wether to show file names (true or false)
 */
$filenames = false;

/* Wether to show subdirectores (true or false)
 */
$subdirs = true;

/* Wether to show a title (true or false)
 */
$title = true;

/* Set the gallery root relative to the script's directory.
 *
 * If you include() this script, set the path relative to
 * the directory of the script, that does the include().
 */
$picdir = '.';

/* Set this to true if you include() this script.
 */
$included = false;

/* Set this to true, if you include() this script and want the images
 * to be shown inline.
 */
$inline = true;

/* Set the thumbnail background color, if you include() this script.
 */
$bg = 'FFFFFF';

/* ------------------------------------------------------------------------- */
switch ($lang) {
case 'de':
 $words = array(
  'gallery' => 'Galerie',
  'src' => 'Quelltext',
  'error' => 'Fehler',
  'php_error' => 'PHP Version 4.1 oder höher ist erforderlich.',
  'gd_error' => 'Die GD-Bibliothek wird benötigt. Siehe http://www.boutell.com/gd/.',
  'jpg_error' => 'Die JPEG-Bibliothek wird benötigt. Siehe ftp://ftp.uu.net/graphics/jpeg/.',
  'mkdir_error' => 'Schreibrecht im Verzeichnis ist erforderlich.',
  'opendir_error' => 'Das Verzeichnis "%1" kann nicht gelesen werden.'
 );
 break;
case 'en':
default:
 $words = array(
  'gallery' => 'gallery',
  'src' => 'source code',
  'error' => 'Error',
  'php_error' => 'PHP >= 4.1 is required.',
  'gd_error' => 'GD Library is required. See http://www.boutell.com/gd/.',
  'jpg_error' => 'JPEG software is required. See ftp://ftp.uu.net/graphics/jpeg/.',
  'mkdir_error' => 'Write permission is required in this folder.',
  'opendir_error' => 'The directory "%1" can not be read.'
 );
}
isset($_SERVER) || $error = error('php', array());
function_exists('imagecreate') || $error = error('gd', array());
function_exists('imagejpeg') || $error = error('jpg', array());
@ini_set('memory_limit', -1);
$jpg = '\.jpg$|\.jpeg$'; $gif = '\.gif$'; $png = '\.png$';
$fontsize = 2;
if (array_key_exists('src', $_REQUEST)) {
 ob_start();
 highlight_file(basename($_SERVER['PHP_SELF']));
 $src = ereg_replace('<font color="([^"]*)">', '<span style="color: \1">', ob_get_contents());
 $src = ereg_replace('</font>', '</span>', $src);
 ob_end_clean();
}
function w ($w) {
 global $words;
 return h($words[$w]);
}
function h ($w) {
 global $charset;
 return htmlentities($w, ENT_COMPAT, $charset);
}
function error ($w, $a) {
 return str_replace(array('%1'), $a, w($w .'_error'));
}
if (!$included) {
 echo('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
body { font-family: sans-serif }
hr { border-style: none; height: 1px; background-color: silver; color: silver }
p { margin: 0px; padding: 0px }
#pagenumbers { text-align: center; margin: 0px 1em 0px 1em }
img { margin: 10px; border: none }
a { text-decoration: none }
#src');
__________________
aaa!!
  #4 (permalink)  
Antiguo 17/07/2006, 19:43
Avatar de El_MiMo  
Fecha de Ingreso: septiembre-2003
Ubicación: Chile
Mensajes: 123
Antigüedad: 20 años, 7 meses
Puntos: 1
continua

sigue acá

Código:
if ($filenames) echo(', div a p'); echo(" { font-size: small }\n");
 if ($filenames) {
  echo(".clear { clear: left }\n");
  echo("a:hover p { text-decoration: underline }\n");
  echo('div { width: ' . ($thumbsize + 20) . 'px; text-align: center; ');
  echo("float: left; margin: 1em }\n");
 }
 echo("</style>\n");
 echo("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$charset\" />\n");
 if (isset($src)) {
  echo('<title>' . w('gallery') . ': ' . w('src') . "</title>\n");
  echo("</head>\n<body>\n");
  echo('<h1>' . w('gallery') . ': ' . w('src') . "</h1>\n<hr />\n<pre>");
  echo("$src</pre>\n</body>\n</html>");
  exit;
 }
}
if (array_key_exists('dir', $_REQUEST) && $subdirs) $dir = $_REQUEST['dir'];
else $dir = '';
if (!empty($_SERVER['PATH_TRANSLATED'])) $d = dirname($_SERVER['PATH_TRANSLATED']);
elseif (!empty($_SERVER['SCRIPT_FILENAME'])) $d = dirname($_SERVER['SCRIPT_FILENAME']);
else $d = getcwd();
$delim = (substr($d, 1, 1) == ':') ? '\\' : '/';
$rp = function_exists('realpath');
if ($rp) $root = realpath($d . $delim . $picdir);
else $root = $d . $delim . $picdir;
if ($rp) $realdir = realpath($root . $dir);
else $realdir = $root . $dir;
if (substr($realdir, 0, strlen($root)) != $root) $realdir = $root;
$dirname = substr($realdir, strlen($root));
$dirnamehttp = $picdir . $dir;
if ($delim == '\\') $dirnamehttp = strtr($dirnamehttp, '\\', '/');
if (substr($dirnamehttp, 0, 2) == './') $dirnamehttp = substr($dirnamehttp, 2);
if (empty($dirnamehttp)) $dirnamehttp = '.';
if ($subdirs) {
 if (empty($dirname)) $ti = ': /.'; else $ti = ": $dirname";
} else $ti = '';
if (!$included) {
 if (isset($error)) echo("<title>$error</title>");
 else echo('<title>' . w('gallery') . h($ti) . "</title>\n");
 echo("</head>\n<body>\n");
}
if (!($d = @opendir($realdir))) $error = error('opendir', array($realdir));
if (isset($error)) echo("<p style=\"color: red\">$error</p>\n");
else {
 if ($title) echo('<h1>' . w('gallery') . h($ti) . "</h1>\n<hr />\n");
 $dirs = $pics = array();
 $query = $jpg;
 if (function_exists('imagecreatefromgif')) $query .= "|$gif";
 if (function_exists('imagecreatefrompng')) $query .= "|$png";
 while (false !== ($filename = readdir($d))) {
  if ($filename == $thumbdir
   || ($filename == '..' && $dirname == '')
   || ($filename != '..' && substr($filename, 0, 1) == '.')) continue;
  $file = $realdir . $delim . $filename;
  if (is_dir($file)) $dirs[] = $filename;
  elseif (eregi($query, $file)) $pics[] = $filename;
 }
 closedir($d);
 sort($dirs);
 sort($pics);
 $urlsuffix = '';
 foreach ($_GET as $v => $r) {
  if (!in_array($v, array('dir', 'pic', 'offset'))) $urlsuffix .= "&$v=" . urlencode($r);
 }
 if ($included && $inline && array_key_exists('pic', $_REQUEST)) {
  $pic = $_REQUEST['pic'];
  echo("<div id=\"picture\">\n");
  echo('<img src="' . h("$dirnamehttp/{$pics[$pic]}") . '" alt="' . h(basename($pics[$pic])) . '"');
  list($width, $height, $type, $attr) = @getimagesize($pic);
  if (!empty($width)) echo(" style=\"width: {$width}px; height: {$height}px\"");
  echo(" />\n");
  $url = ($dirname  == '') ? '?' : '?dir=' . urlencode($dirname) . '&';
  echo("<hr />\n");
  if ($pic > 0)
  echo('<a href="' . h($url) . 'pic=' . ($pic - 1) . h($urlsuffix) . '">[&lt;]</a> ');
  if ($pic >= $maxpics)
  $u = "{$url}offset=" . (floor($pic / $maxpics) * $maxpics) . $urlsuffix;
  else {
   if (array_key_exists('dir', $_REQUEST)) {
    $u = substr($url, 0, strlen($url) - 1) . $urlsuffix;
   } else {
    $u = ereg_replace('^([^?]+).*$', '\1', $_SERVER['REQUEST_URI']);
    if (!empty($urlsuffix)) {
     if (strstr($u, '?') === false) $u .= '?' . substr($urlsuffix, 1);
     else $u .= $urlsuffix;
    }
   }
  }
  echo('<a href="' . h($u) . '">[-]</a>');
  if ($pic + 1 < sizeof($pics))
  echo(' <a href="' . h($url) . 'pic=' . ($pic + 1) . h($urlsuffix) . '">[&gt;]</a>');
  echo("\n</div>\n");
 } else {
  if (sizeof($dirs) > 0 && $subdirs) {
   echo("<ul id=\"directories\">\n");
   foreach ($dirs as $filename) {
    if ($rp) $target = substr(realpath($realdir . $delim . $filename), strlen($root));
    else $target = substr($realdir . $delim . $filename, strlen($root));
    if ($delim == '\\') $target = strtr($target, '\\', '/');
    if ($target == '') {
     $url = ereg_replace('^([^?]+).*$', '\1', $_SERVER['REQUEST_URI']);
     if (!empty($urlsuffix)) {
      if (strstr($url, '?') === false) $url .= '?' . substr($urlsuffix, 1);
      else $url .= $urlsuffix;
     }
    } else $url = '?dir=' . urlencode($target) . $urlsuffix;
    echo('<li><a href="' . h($url) . '">' . h($filename) . "</a></li>\n");
   }
   echo("</ul>\n<hr />\n");
  }
  if (($num = sizeof($pics)) > 0) {
   if (array_key_exists('offset', $_REQUEST)) $offset = $_REQUEST['offset'];
   else $offset = 0;
   if ($num > $maxpics) {
    echo("<p id=\"pagenumbers\">\n");
    for ($i = 0; $i < $num; $i += $maxpics) {
     $e = $i + $maxpics - 1;
     if ($e > $num - 1) $e = $num - 1;
     if ($i != $e) $b = ($i + 1) . '-' . ($e + 1);
     else $b = $i + 1;
     if ($i == $offset) echo("<b>$b</b>");
     else {
      $url = ($dirname  == '') ? '?' : '?dir=' . urlencode($dirname) . '&amp;';
      echo("<a href=\"{$url}offset=$i" . h($urlsuffix) . "\">$b</a>");
     }
     if ($e != $num - 1) echo(' |');
     echo("\n");
    }
    echo("</p>\n<hr />\n");
   }
   echo("<p id=\"pictures\">\n");
   for ($i = $offset; $i < $offset + $maxpics; $i++) {
    if ($i >= $num) break;
    $filename = $pics[$i];
    $file = $realdir . $delim . $filename;
    if (!is_readable($file)) continue;
    if (!is_dir($realdir . $delim . $thumbdir)) {
     $u = umask(0);
     if (!@mkdir($realdir . $delim . $thumbdir, 0777)) {
      echo('<p style="color: red; text-align: center">' . w('mkdir_error') . '</span>');
 
     break;
     }
     umask($u);
    }
    $thumb = $realdir . $delim . $thumbdir . $delim . $filename . '.thumb.jpg';
    if (!is_file($thumb)) {
     if (eregi($jpg, $file))
     $original = @imagecreatefromjpeg($file);
     elseif (eregi($gif, $file))
     $original = @imagecreatefromgif($file);
     elseif (eregi($png, $file))
     $original = @imagecreatefrompng($file);
     else continue;
     if ($original) {
      if (function_exists('getimagesize'))
      list($width, $height, $type, $attr) = getimagesize($file);
      else continue;
      if ($width > $height && $width > $thumbsize) {
       $smallwidth = $thumbsize;
       $smallheight = floor($height / ($width / $smallwidth));
       $ofx = 0; $ofy = floor(($thumbsize - $smallheight) / 2);
      } elseif ($width < $height && $height > $thumbsize) {
       $smallheight = $thumbsize;
       $smallwidth = floor($width / ($height / $smallheight));
       $ofx = floor(($thumbsize - $smallwidth) / 2); $ofy = 0;
      } else {
       $smallheight = $height;
       $smallwidth = $width;
       $ofx = floor(($thumbsize - $smallwidth) / 2);
       $ofy = floor(($thumbsize - $smallheight) / 2);
      }
     }
     if (function_exists('imagecreatetruecolor'))
$small = imagecreatetruecolor($thumbsize, $thumbsize);
     else $small = imagecreate($thumbsize, $thumbsize);
     sscanf($bg, "%2x%2x%2x", $red, $green, $blue);
     $b = imagecolorallocate($small, $red, $green, $blue);
     imagefill($small, 0, 0, $b);
     if ($original) {
      if (function_exists('imagecopyresampled'))
imagecopyresampled($small, $original, $ofx, $ofy, 0, 0, $smallwidth, $smallheight, $width, $height);
      else
imagecopyresized($small, $original, $ofx, $ofy, 0, 0, $smallwidth, $smallheight, $width, $height);
     } else {
      $black = imagecolorallocate($small, 0, 0, 0);
      $fw = imagefontwidth($fontsize);
      $fh = imagefontheight($fontsize);
      $htw = ($fw * strlen($filename)) / 2;
      $hts = $thumbsize / 2;
      imagestring($small, $fontsize, $hts - $htw, $hts - ($fh / 2), $filename, $black);
imagerectangle($small, $hts - $htw - $fw - 1, $hts - $fh, $hts + $htw + $fw - 1, $hts + $fh, $black);
     }
     imagejpeg($small, $thumb);
    }
    if ($filenames) echo('<div>');
    if ($included && $inline) {
    echo('<a href="?');
    if (array_key_exists('dir', $_REQUEST)) echo('dir=' . urlencode($_REQUEST['dir']) . '&amp;');
    echo('pic=' . $i . h($urlsuffix));
    } else echo('<a href="' . h("$dirnamehttp/$filename"));
    echo('"><img src="' . h("$dirnamehttp/thumbs/$filename.thumb.jpg"));
    echo('" alt="' . h($filename) . '" style="');
    echo("width: {$thumbsize}px; height: {$thumbsize}px\" />");
    if ($filenames) echo('<p>' . h($filename) . '</p>');
    echo('</a>');
    if ($filenames) echo("</div>\n"); else echo("\n");
   }
   echo("</p>\n");
   if (!$included) {
    echo('<hr');
    if ($filenames) echo(' class="clear"');
    echo(" />\n");
   }
  }
 }
 if (!$included) echo('<p id="src"><a href="?src=true">' . w('src') . "</a></p>\n");
}
if (!$included) echo("</body>\n</html>");
?>
__________________
aaa!!
  #5 (permalink)  
Antiguo 17/07/2006, 22:35
Avatar de djwarez  
Fecha de Ingreso: diciembre-2005
Ubicación: Colima México
Mensajes: 1.219
Antigüedad: 18 años, 4 meses
Puntos: 5
Gracias por eso.. esta muy bien lo ocuparé, seri bueno meterlo en las FAQS
__________________
"I miss you so. Wath I Do...?"
www.djwarezweblog.com
  #6 (permalink)  
Antiguo 18/07/2006, 02:34
 
Fecha de Ingreso: junio-2003
Mensajes: 940
Antigüedad: 20 años, 10 meses
Puntos: 8
Muchas gracias, yo también he encontrado esta:
http://www.dynamicdrive.com/dynamici...photoalbum.htm
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:15.