Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Tratamiento de Imagenes, como hacer que se vea de dos maneras

Estas en el tema de Tratamiento de Imagenes, como hacer que se vea de dos maneras en el foro de Frameworks JS en Foros del Web. Amigos tengo esto: La pregunta que quiero es como hacer para verla tipo lightbox, como adaptar esto para verlo??? Tengo este codigo adaptado para ello: ...
  #1 (permalink)  
Antiguo 30/06/2009, 15:57
 
Fecha de Ingreso: diciembre-2008
Mensajes: 454
Antigüedad: 15 años, 4 meses
Puntos: 2
Tratamiento de Imagenes, como hacer que se vea de dos maneras

Amigos tengo esto:


La pregunta que quiero es como hacer para verla tipo lightbox, como adaptar esto para verlo???

Tengo este codigo adaptado para ello:
Código PHP:
require_once('GDImageManipulation.class.php');
$filename="IMG_1234.jpg";

function 
recycle() {
    global 
$imageManipulation;
    global 
$filename;
    unset(
$imageManipulation);
    
$imageManipulation = new GDImageManipulation();
    
$imageManipulation->set_image_asFile($filename);
    return 
$imageManipulation;


$imageManipulation = new GDImageManipulation();
// fit_width
// usage: fit_width(int $pixel [,bool $enlarge_small_images]);

$imageManipulation recycle();
$imageManipulation->fit_height('100'true);
echo 
$imageManipulation->get_inlineTag_png('jpg');

$imageManipulation recycle();
$imageManipulation->fit_height('600'true);
echo 
$imageManipulation->get_inlineTag_png('jpg'); 
continua >>>
  #2 (permalink)  
Antiguo 30/06/2009, 15:59
 
Fecha de Ingreso: diciembre-2008
Mensajes: 454
Antigüedad: 15 años, 4 meses
Puntos: 2
Respuesta: Tratamiento de Imagenes, como hacer que se vea de dos maneras

Aqui esta GDImageManipulation.class.php:
Código PHP:
Class GDImageManipulation
{
    
/*
     * Variable declarations
     */

    
private $image_file         ""// Filename and path for disc-input
    
private $image_object       ""// Input image object
    
private $image_width        ""// Input image width
    
private $image_height       ""// Input image height

    /*
     * Function declaration
     */

    
public function set_image_asFile($filename)
    {
        
$this->image_file $filename;
        
$handle fopen($filename"r");
        
$this->image_object imagecreatefromstring(fread($handlefilesize($filename)));
        
fclose($handle);

        
$this->image_width imagesx($this->image_object);
        
$this->image_height imagesy($this->image_object);
        return 
true;
    } 
// function set_image_file

  
    
public function set_image_asString($string)
    {
        
$this->image_object imagecreatefromstring($string);
        
$this->image_width imagesx($this->image_object);
        
$this->image_height imagesy($this->image_object);
        return 
true;    
    } 
// function set_image_string


    
public function set_image_asObject($object)
    {
        
$this->image_object $object;
        
$this->image_width imagesx($this->image_object);
        
$this->image_height imagesy($this->image_object);
        return 
true;                
    } 
// function set_image_string   

    
    
public function get_png()
    {
        if (
$this->image_object)
        {
            return 
imagepng($this->image_object);
        } else {
        return 
false;
        }
    } 
// function get_png


    
public function get_gd2()
    {
        if (
$this->image_object)
        {
            return 
imagegd2($this->image_object);
        } else {
        return 
false;
        }
    } 
// function get_gd2


    
public function get_gd()
    {
        if (
$this->image_object)
        {
            return 
imagegd($this->image_object);
        } else {
        return 
false;
        }
    } 
// function get_gd


    
public function get_gif()
    {
        if (
$this->image_object)
        {
            return 
imagegif($this->image_object);
        } else {
        return 
false;
        }
    } 
// function get_gif


    
public function get_jpeg()
    {
        if (
$this->image_object)
        {
            return 
imagejpeg($this->image_object);
        } else {
        return 
false;
        }
    } 
// function get_jpg


    
public function get_inlineTag_png($alt)
    {
        if (
$this->image_object)
        {
            
ob_start();
            
imagepng($this->image_object);
            
$raw ob_get_clean();
            
ob_end_clean();
            
$data chunk_split(base64_encode($raw));
            
//$data = str_replace(array('+','/','='),array('-','_',),$data);
            
$tag  '<img src="data:image/png;base64,'.$data.'"';
            
$tag .= ' width="'.imagesx($this->image_object).'"';
            
$tag .= ' height="'.imagesy($this->image_object).'"';
            
$tag .= ' alt="'.$alt.'" />';
            
            return 
$tag;
        } else {
        return 
false;
        }
    }


    public function 
get_inlineTag_gif($alt)
    {
        if (
$this->image_object)
        {
            
ob_start();
            
imagegif($this->image_object);
            
$raw ob_get_clean();
            
ob_end_clean();
            
$data chunk_split(base64_encode($raw));
            
//$data = str_replace(array('+','/','='),array('-','_',),$data);
            
$tag  '<img src="data:image/gif;base64,'.$data.'"';
            
$tag .= ' width="'.imagesx($this->image_object).'"';
            
$tag .= ' height="'.imagesy($this->image_object).'"';
            
$tag .= ' alt="'.$alt.'" />';
            
            return 
$tag;
        } else {
        return 
false;
        }
    }

    public function 
get_inlineTag_jpeg($alt)
    {
        if (
$this->image_object)
        {
            
ob_start();
            
imagejpeg($this->image_object);
            
$raw ob_get_clean();
            
ob_end_clean();
            
$data chunk_split(base64_encode($raw));
            
//$data = str_replace(array('+','/','='),array('-','_',),$data);
            
$tag  '<img src="data:image/jpeg;base64,'.$data.'"';
            
$tag .= ' width="'.imagesx($this->image_object).'"';
            
$tag .= ' height="'.imagesy($this->image_object).'"';
            
$tag .= ' alt="'.$alt.'" />';
            
            return 
$tag;
        } else {
        return 
false;
        }
    }

    public function 
fit_width($width$enlarge)
    {
        if ( 
$this->image_width $width or ($enlarge and $this->image_width $width))
        {
            
$nwidth $width;
            
$nheight intval(($width $this->image_width) * $this->image_height); 

            
$scaledImage ImageCreateTrueColor($nwidth$nheight);
            
ImageCopyResampled($scaledImage$this->image_object0000
                               
$nwidth$nheight$this->image_width$this->image_height);

            
$this->set_image_asObject($scaledImage);
        }
        return 
true;
    } 
// function fit_width


    
public function fit_height($height$enlarge)
    {
        if ( 
$this->image_height $height or ($enlarge and $this->image_height $height))
        {
            
$nheight $height;
            
$nwidth intval(($height $this->image_height) * $this->image_width); 

            
$scaledImage ImageCreateTrueColor($nwidth$nheight);
            
ImageCopyResampled($scaledImage$this->image_object0000
                               
$nwidth$nheight$this->image_width$this->image_height);
        
            
$this->set_image_asObject($scaledImage);
        }
        return 
true;    
    } 
// function fit_height


    
public function resize($factor)
    {
        
$nheight intval($this->image_height $factor);
        
$nwidth  intval($this->image_width $factor);
        
$scaledImage ImageCreateTrueColor($nwidth$nheight);
        
ImageCopyResampled($scaledImage$this->image_object0000
                           
$nwidth$nheight$this->image_width$this->image_height);
        
$this->set_image_asObject($scaledImage);
        return 
true;
    } 
// function resize


    
public function flip_vertical()
    {
        
$dest imagecreatetruecolor(imagesx($this->image_object), imagesy($this->image_object));
        
ImageCopyResampled($dest$this->image_object000
                            (
imagesy($dest)-1), imagesx($dest), imagesy($dest), imagesx($dest), 
                            (
0-imagesy($dest)));
        
$this->set_image_asObject($dest);
        return 
true;
    }


    public function 
flip_horizontal()
    {
        
$dest imagecreatetruecolor(imagesx($this->image_object), imagesy($this->image_object));
        
ImageCopyResampled($dest$this->image_object00
                            (
imagesx($dest)-1), 0imagesx($dest), 
                            
imagesy($dest), (0-imagesx($dest)), imagesy($dest));
        
$this->set_image_asObject($dest);
        return 
true;
    }


    public function 
rotate($angle$r=255$g=255$b=255$ignore_transparent=-1)
    {
        if (
$this->image_object) {
            
$bgcolor imagecolorallocate($this->image_object$r$g$b);
            
$this->image_object imagerotate($this->image_object$angle$bgcolor$ignoretransparent);
            
$bgcolor imagecolorallocate($this->image_object$r$g$b);
            return 
true;
        } else {
            return 
false;
        }
    
    }


    public function 
convert_sepia($dither true)
    {
        
// Credits: derek at idreams dot co dot uk
        // Source: http://de.php.net/manual/en/function.imagecolorsforindex.php#79511       

        
if (!($t imagecolorstotal($this->image_object))) {
            
$t 256;
            
imagetruecolortopalette($this->image_object$dither$t);
        }

        
$total imagecolorstotal$this->image_object );

        for ( 
$i 0$i $total$i++ ) {
            
$index imagecolorsforindex$this->image_object$i );
                
$red = ( $index["red"] * 0.393 $index["green"] * 0.769 $index["blue"] * 0.189 );
                
$green = ( $index["red"] * 0.349 $index["green"] * 0.686 $index["blue"] * 0.168 ); 
                
$blue = ( $index["red"] * 0.272 $index["green"] * 0.534 $index["blue"] * 0.131 ); 

        if (
$red 255) { $red 255; }
        if (
$green 255) { $green 255; }
        if (
$blue 255) { $blue 255; }
        
imagecolorset$this->image_object$i$red$green$blue );
        }    
    }

//continua en la siguiente cita 
  #3 (permalink)  
Antiguo 30/06/2009, 15:59
 
Fecha de Ingreso: diciembre-2008
Mensajes: 454
Antigüedad: 15 años, 4 meses
Puntos: 2
Respuesta: Tratamiento de Imagenes, como hacer que se vea de dos maneras

continuacion:
Código PHP:
    public function convert_colorize($tint_r=0$tint_g=0$tint_b=0$tint_alpha=0)
    {
        if (
$this->image_object) {
            
imagefilter ($this->image_objectIMG_FILTER_COLORIZE$tint_r$tint_g$tint_b);
            return 
true;
        } else {
            return 
false;
        }        
    }


    public function 
convert_negate()
    {
        if (
$this->image_object) {
            
imagefilter ($this->image_objectIMG_FILTER_NEGATE);
            return 
true;
        } else {
            return 
false;
        }
    }

    public function 
convert_grayscale()
    {
        if (
$this->image_object) {
            
imagefilter ($this->image_objectIMG_FILTER_GRAYSCALE);
            return 
true;
        } else {
            return 
false;
        }
    }


    public function 
convert_brightness($level)
    {
        if (
$this->image_object) {
            
imagefilter ($this->image_objectIMG_FILTER_BRIGHTNESS$level);
            return 
true;
        } else {
            return 
false;
        }
    }


    public function 
convert_contrast($level)
    {
        if (
$this->image_object) {
            
imagefilter ($this->image_objectIMG_FILTER_CONTRAST$level);
            return 
true;
        } else {
            return 
false;
        }
    }


    public function 
convert_edgedetect()
    {
        if (
$this->image_object) {
            
imagefilter ($this->image_objectIMG_FILTER_EDGEDETECT);
            return 
true;
        } else {
            return 
false;
        }
    }


    public function 
convert_emboss()
    {
        if (
$this->image_object) {
            
imagefilter ($this->image_objectIMG_FILTER_EMBOSS);
            return 
true;
        } else {
            return 
false;
        }
    }

    public function 
convert_gaussian_blur()
    {
        if (
$this->image_object) {
            
imagefilter ($this->image_objectIMG_FILTER_GAUSSIAN_BLUR);
            return 
true;
        } else {
            return 
false;
        }
    }

    public function 
convert_selective_blur()
    {
        if (
$this->image_object) {
            
imagefilter ($this->image_objectIMG_FILTER_SELECTIVE_BLUR);
            return 
true;
        } else {
            return 
false;
        }
    }

    public function 
convert_mean_removal()
    {
        if (
$this->image_object) {
            
imagefilter ($this->image_objectIMG_FILTER_MEAN_REMOVAL);
            return 
true;
        } else {
            return 
false;
        }
    }

    public function 
convert_smooth($level)
    {
        if (
$this->image_object) {
            
imagefilter ($this->image_objectIMG_FILTER_SMOOTH$level);
            return 
true;
        } else {
            return 
false;
        }
    }


    public function 
save_png($filename$overwrite)
    {
        if (!
$overwrite and file_exists($filename)) {
            return 
false;
        }

        if (
$this->image_object) {
            
imagepng($this->image_object$filename);
            return 
true;
        } else {
            return 
false;
        }
    }


    public function 
save_gd2($filename$overwrite)
    {
        if (!
$overwrite and file_exists($filename)) {
            return 
false;
        }

        if (
$this->image_object) {
            
imagegd2($this->image_object$filename);
            return 
true;
        } else {
            return 
false;
        }
    }

    public function 
save_gd($filename$overwrite)
    {
        if (!
$overwrite and file_exists($filename)) {
            return 
false;
        }

        if (
$this->image_object) {
            
imagegd($this->image_object$filename);
            return 
true;
        } else {
            return 
false;
        }
    }

    public function 
save_gif($filename$overwrite)
    {
        if (!
$overwrite and file_exists($filename)) {
            return 
false;
        }

        if (
$this->image_object) {
            
imagegif($this->image_object$filename);
            return 
true;
        } else {
            return 
false;
        }
    }

    public function 
save_jpeg($filename$overwrite)
    {
        if (!
$overwrite and file_exists($filename)) {
            return 
false;
        }

        if (
$this->image_object) {
            
imagejpeg($this->image_object$filename);
            return 
true;
        } else {
            return 
false;
        }
    }


continua>>>
  #4 (permalink)  
Antiguo 30/06/2009, 16:03
 
Fecha de Ingreso: diciembre-2008
Mensajes: 454
Antigüedad: 15 años, 4 meses
Puntos: 2
Respuesta: Tratamiento de Imagenes, como hacer que se vea de dos maneras

La pregunta es:

Como hacer para dicha imagen tipo lightbox??


tengo esto pero no se como hacerlo
Código HTML:
<html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin t&iacute;tulo</title>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="lightbox.js"></script>
<link rel="stylesheet" href="lightbox.css" type="text/css" media="screen" />
</head>

<body>
<a href="<!--aqui deberia de ir la imagen grande de 600-->" title="imagen 1" rel="lightbox[roadtrip]"><img src="<!--aqui deberia de ir la imagen pequeña de 100-->" alt="Plant 1" /></a>
</body>
</html> 
como hacer para que el codif¿go del principio se adapte a esto??

Última edición por easy; 30/06/2009 a las 16:08
  #5 (permalink)  
Antiguo 30/06/2009, 16:29
 
Fecha de Ingreso: diciembre-2008
Mensajes: 454
Antigüedad: 15 años, 4 meses
Puntos: 2
Respuesta: Tratamiento de Imagenes, como hacer que se vea de dos maneras

hice esto pero no me imprimer las imagenes
Código HTML:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin t&iacute;tulo</title>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="lightbox.js"></script>
<link rel="stylesheet" href="lightbox.css" type="text/css" media="screen" />
</head>

<body>
<?
require_once('GDImageManipulation.class.php');
$filename="IMG_1234.jpg";

function recycle() {
    global $imageManipulation;
    global $filename;
    unset($imageManipulation);
    $imageManipulation = new GDImageManipulation();
    $imageManipulation->set_image_asFile($filename);
    return $imageManipulation;
} 

$imageManipulation = new GDImageManipulation();


$imageManipulation = recycle();
$imageManipulation->fit_height('100', true);
echo "<a href='";
echo $imageManipulation->get_inlineTag_png('jpg');
echo "' title='imagen 1' rel='lightbox[roadtrip]'><img src='";

$imageManipulation = recycle();
$imageManipulation->fit_height('600', true);
echo $imageManipulation->get_inlineTag_png('jpg');
echo "' alt='Plant 1' /></a>";

?>
<br /><br />
<a href="images/IMG_1072_2.jpg" title="imagen 1" rel="lightbox[roadtrip]"><img src="images/IMG_1072.jpg" alt="Plant 1" /></a>
</body>
</html> 
Ayudenme porfa
  #6 (permalink)  
Antiguo 30/06/2009, 18:59
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Tratamiento de Imagenes, como hacer que se vea de dos maneras

Tema trasladado desde PHP
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 04:48.