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

Código:
 	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);

	}		 
	
?>
PHP

Código:
<table width='700' cellpadding='0' cellspacing='0'>
<tr valign='top'><td width='350' align='center'><?php

	if(file_exists($_SERVER[DOCUMENT_ROOT] . "/proyectocrossh/img/productos/1-" . $data_id . ".jpg")) {

	
		echo "<a href='/proyectocrossh/img/productos/1-" . $data_id . ".jpg' title='" . $data_titulo  . "' class='cpModal' rel='galeria'><img src='/proyectocrossh/img/productos/1-" . $data_id . ".jpg' alt='" . $data_titulo . "' border='0' width='350' height='350' /></a>";
		
	}
	else
	{
		echo "<img src='/proyectocrossh/img/trans.gif' alt='" . $data_titulo . "' border='0' width='350' height='300' />";
	}
	
?></td><td><div class='descripcion'>
<h1><?php echo ucwords(strtolower($data_titulo)) ; ?></h1>
<h2>Nº Referencia: <?php echo $data_referencia; ?></h2>
<p><?php echo $data_interna; ?></p>
<h3>Precio: <?php /*?><?php echo money_format('%.2n', $data_precio); ?><?php */?></h3>
</div>
<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/t-" . $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/t-" . $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/t-" . $a . "-" . $data_id . ".jpg' alt='" . $data_titulo . "' border='0' vspace='3' hspace='3'  /></a>";
			
		}
	
	}
	
?>

</div>



</td></tr></table></div>