Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Temas - antoni_anemi

#1
PHP / como hacer tumbs de imagenes en php
15 Julio 2012, 17:37 PM
NECESITO AYUDA ESTOY HACIENDO UN PROGRAMA EN PHP QUE CREE IMAGENES TUMBS Y QUE LOS GUARDE EN UN DIRECTORIO ME HACE TODO ME CREA EL DIRECTORIO Y LA IMAGEN TUMBS PERO SOLO ME CREA UNA IMAGEN EN NEGRO NO ME COPIA LA IMAGEN ORIGINAL ESTE ES MI CODIGO OJALA ME PUEDAN AYUDAR



<?php
/**
* @author antonio de jesus cortes lagunes
* @copyright 2012
* este es puro codigo php si desea verlo en el explorador tienes que meterlo en codigo html y
* ademas debes tener instalado php para que pueda ser interpretado.
*
* Ejercicio 4.10: ídem al anterior, pero que si no existe la miniatura de una foto debe de crearla.
* VERSION PARA WINDOWS
*
*/

echo "<h1>Galeria de imagenes con thumbnails</h1>";



function png($foto){
        if (!is_dir('fotos/tumbs')){
        mkdir ('fotos/tumbs', 0777);
    }
    header('Content-Type: image/gif');
$fuente = @imagecreatefrompng($foto);
$imgAncho = imagesx ($fuente);
$imgAlto =imagesy($fuente);
$imagen = imagecreatetruecolor(50,50);

imagecopyresampled($imagen,$fuente,0,0,0,0,50,50,$imgAncho,$imgAlto);


imageGif($imagen,"fotos/tumbs/MINI-$foto");
   
}



function jpg($foto){
    if (!is_dir('fotos/tumbs')){
        mkdir ('fotos/tumbs', 0777);
    }
header('Content-Type: image/jpeg');
$fuente = @imagecreatefromjpeg($foto);
$imgAncho = imagesx($fuente);
$imgAlto =imagesy($fuente);
$imagen = imagecreatetruecolor(50,50);

imagecopyresampled($imagen,$fuente,0,0,0,0,100,100,$imgAncho,$imgAlto);



imagejpeg($imagen,"fotos/tumbs/MINI-$foto");
   
}

function gif($foto){
        if (!is_dir('fotos/tumbs')){
        mkdir ('fotos/tumbs', 0777);
    }
    header('Content-Type: image/gif');
$fuente = @imagecreatefromgif($foto);
$imgAncho = imagesx ($fuente);
$imgAlto =imagesy($fuente);
$imagen = imagecreatetruecolor(50,50);

imagecopyresampled($imagen,$fuente,0,0,0,0,50,50,$imgAncho,$imgAlto);


imageGif($imagen,"fotos/tumbs/MINI-$foto");
   
}




function valida_foto($fotos)
{
$rdo=0;
if (ereg("[Jj][Pp][Gg]$", $fotos)) {
    $rdo=1;
    jpg($fotos);
}
if (ereg("[Gg][Ii][Ff]$", $fotos)) {
    $rdo=1;
    gif($fotos);
}
if (ereg("[Pp][Nn][Gg]$", $fotos)){
    $rdo=1;
    png($fotos);
}
if (ereg("[Bb][Mm][Pp]$", $fotos)) {
    $rdo=1;
    bmp($fotos);
}
return $rdo;
}




echo "<table border=1>";
$puntero = opendir('fotos');
$i=1;
while (false !== ($foto = readdir($puntero)))
{
if ($foto!="." && $foto!=".." && valida_foto($foto))
{

if ($i==1)
echo "<tr>";
echo "<td><a href='fotos/tumbs/MINI-$foto'>";
echo "<img src='fotos/$foto' width=100 height=100></img>";

echo "</a></td>";
if ($i==4)
{echo "</tr>"; $i=0;}
$i++;
}
}
closedir($puntero);
echo "</table>";



?>
#2
MI DUDA ES LA SIGUIENTE TENGO WAMP SERVER INSTALADO YA SUBO MIS PAGINAS AGO PRUEBAS Y TODO.
PERO COMO LE AGO PARA QUE EN UNA RED LAN TODAS LAS DEMAS PC PUEDAN ACCEDER A LAS PAGINAS DEL SERVIDOR. YA INTENTE MODIFICANDO EL ARCHIVO DEL SERVIDOR APACHE PARA QUE NO SOLO ACEPTE CONEXIONES DE LOCALHOST PERO AUN ASI NO PUEDO HACER QUE OTRA PC ACCEDA???