Ver Mensaje Individual
  #3 (permalink)  
Antiguo 17/04/2002, 18:38
cholyberreteaga
 
Fecha de Ingreso: enero-2002
Ubicación: Buenos Aires, Argentina
Mensajes: 193
Antigüedad: 22 años, 3 meses
Puntos: 0
Re: Galeria de Fotos en PHP

yo he hecho una galeria dinamica que funciona sin base de datos, osea, solo con indicar el directorio: conste de dos archivos:
index.php
------------------
<table border=1 bordercolor=black cellpadding=4 cellspacing=2><tr><?
$max = "3"; // máximo de fotos por fila
$num = 0;
$abrir=opendir("img/"); // aqui defines el directorio de imagenes
while ($img=readdir($abrir)){
$x1 = explode(".", "$img");
$x2 = count($x1);
if(($x1[$x2-1] == jpg) || ($x1[$x2-1] == JPG) || ($x1[$x2-1] == gif) || ($x1[$x2-1] == GIF)){
$num++;
if($num > $max){
echo"<tr>";
}
if(($x1[$x2-1] == jpg) || ($x1[$x2-1] == JPG)){
$src= "escala.php?id=$img";
}else{
$src= "img/$img";
}
$fecha = filectime("img/$img");
$fecha = date("d/m/Y", $fecha);
$tamano = filesize("img/$img");
echo"<td><center><a href='img/$img'><img src=\"$src\" border=0 width=100 height=100></a></center><br><font size=1 face=verdana><b>Nombre</b> : $img<br><b>Fecha</b> : $fecha<br><b>Tamaño</b> : $tamano bytes</font></td>";
if($num == $max){
echo"</tr>";
$num=0;
}
$fecha = "";
$tamano = "";
}
}
?>
</tr>
</table>

escala.php
----------------------
<?
$sz = 200;
$im = imagecreatefromJpeg("img/$id"); // fijate que este bien la direccion hacia el directorio
$im_width=imageSX($im);
$im_height=imageSY($im);
if($im_width >= $im_height)
{
$factor = $sz/$im_width;
$new_width = $sz;
$new_height = $im_height * $factor;
}
else
{
$factor = $sz/$im_height;
$new_height = $sz;
$new_width = $im_width * $factor;
}

// achicamos
$new_im=ImageCreate($new_width,$new_height);
ImageCopyResized($new_im,$im,0,0,0,0,$new_width,$n ew_height,$im_width,$im_height);
header("Content-type: image/jpeg");
Imagejpeg($new_im,'',75); // quality 75
ImageDestroy($im);
ImageDestroy($new_im);
?>
------
ok con estos dos archivos juntos y una carpeta con las imagenes llamada "img" se supone q funcionara, tiene una particularidad,en caso de ser jpeg la se crea una imagen a escala, espero te sirva.
choly be. :)

<iframe target="_top" src="http://genteloca.com/firma.htm" width="100%" height="70" border="0" framespacing="0" border="0" frameborder="0"> </iframe>