Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/03/2011, 10:27
Anna Carolina
 
Fecha de Ingreso: febrero-2007
Ubicación: Caracas
Mensajes: 148
Antigüedad: 17 años, 2 meses
Puntos: 6
Ayudita con la funcion de las imagenes cortadas

Este es el codigo


Codigo PHP
Muestra la imagen en miniatura

<div class='galeria' style="text-align: center; padding: 10px 10px 10px 10px;"><?php for($a=2; $a<=10; $a++) { if(file_exists($_SERVER[DOCUMENT_ROOT] . "/proyectocrossh/img/productos/" . $a . "-" . $data_id . ".jpg")) { if((!(file_exists($_SERVER[DOCUMENT_ROOT] . "/proyectocrossh/img/productos/t-" . $a . "-" . $data_id . ".jpg"))) OR (filemtime($_SERVER[DOCUMENT_ROOT] . "/proyectocrossh/img/productos/2-" . $a . "-" . $data_id . ".jpg")<($timestamp-18000))) { @cropImage(100, 111,$_SERVER[DOCUMENT_ROOT] . "/proyectocrossh/img/productos/" . $a . "-" . $data_id . ".jpg", "jpg",$_SERVER[DOCUMENT_ROOT] . "/proyectocrossh/img/productos/2-" . $a . "-" . $data_id . ".jpg"); } echo "<a href='/proyectocrossh/img/productos/" . $a . "-" . $data_id . ".jpg' title='" . $data_titulo . "' class='cpModal' rel='galeria'><img src='/proyectocrossh/img/productos/2-" . $a . "-" . $data_id . ".jpg' alt='" . $data_titulo . "' border='0' vspace='3' hspace='3' /></a>"; } } ?></div>

Funcion de Imagen miniatura corta, pega y guarda

----------------------------------------------------------------------------------------------------------------------------------------------------------------------
function cropImage($nw, $nh, $source, $stype, $dest) { $size = getimagesize($source); $w = $size[0]; $h = $size[0]; switch($stype) { case 'gif': $simg = imagecreatefromgif($source); break; case 'jpg': $simg = imagecreatefromjpeg($source); break; case 'png': $simg = imagecreatefrompng($source); break; } $dimg = imagecreatetruecolor($nw, $nh); $wm = $w/$nw; $hm = $h/$nh; $h_height = $nh/2; $w_height = $nw/2; if($w> $h) { $adjusted_width = $w / $hm; $half_width = $adjusted_width /2; $int_width = $half_width - $w_height; imagecopyresampled($dimg,$simg,-$int_width,0,0,0,$adjusted_width,$nh,$w,$h); } elseif(($w <$h) || ($w == $h)) { $adjusted_height = $h / $wm; $half_height = $adjusted_height / 2; $int_height = $half_height - $h_height; imagecopyresampled($dimg,$simg,0,-$int_height,0,0,$nw,$adjusted_height,$w,$h); } else { imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$nh,$w, $h); } imagejpeg($dimg,$dest,100); } ?>


------------------------------------------------------------------------------------------------------------------------------------

Nota: al nombrar las variables de la imagen iniciando en 0, me ajusta la imagen, pero lo que quiero es ajustarla al recuadro, para que no salga negro en los espacios.Ahhhhh Auxilio >:(