Ver Mensaje Individual
  #3 (permalink)  
Antiguo 13/06/2011, 12:48
Avatar de Hugo_Euan
Hugo_Euan
 
Fecha de Ingreso: abril-2011
Ubicación: Mérida, Yucatán, México
Mensajes: 193
Antigüedad: 13 años
Puntos: 71
Respuesta: Fijar tamaño Celda/foto

=D jejeje, bueno pues como te dije... si estas usando PHP para imprimir las imagenes que me imagino que si, por que las estas obteniendo de una BD puedes hacer uso de esta funcion...

Código PHP:
Ver original
  1. function imageResize($width, $height, $_MaxWidth, $_MaxHeight, $OtherPass) {
  2.         if ($width > $height) {
  3.             $percentage = ($_MaxWidth / $width);
  4.         } else {
  5.             $percentage = ($_MaxHeight / $height);
  6.         }
  7.             $width = round($width * $percentage);
  8.             $height = round(($height * $percentage));
  9.             if($width > $_MaxWidth){
  10.                 $TempWidth = ($width - $_MaxWidth);
  11.                 $width = ($width - $TempWidth);
  12.                 $height = ($height - $TempWidth);
  13.             }
  14.             if($height > $_MaxHeight){
  15.                 $TempHeight = ($height - $_MaxHeight);
  16.                 $height = ($height - $TempHeight);
  17.                 $width = ($width - $TempHeight);
  18.             }
  19.             if($OtherPass){
  20.                 imageResize($width, $height, $_MaxWidth, $_MaxHeight, false);
  21.             }
  22.             return "width=\"$width\" height=\"$height\"";
  23. }

lo que hace esta funcion es ajustar las dimensiones de una imagen a un contenedor, en este caso tu celda de 200px...

los parametros que recibe esta funcionn son:

- El ancho de la imagen
- El alto de la imagen
- El Anchio maximo en tu caso 200px
- El alto Maximo si no tienes puedes ponerle 10px por ejemplo..
- Valor Boleano que indica si se hace una segunda pasada....

para usarla solo necesitas obtener el tamaño de la imagen....
y para hacer eso puedes hacer uso de la funcion de PHP getimagesize
por ejemplo...



Código PHP:
Ver original
  1. $src = "Ruta de tu imagen"
  2.  
  3. $tamano = getimagesize($src);
  4.  
  5. $reducir = imageResize($tamano[0], $tamano[1], 200, 10, true);
  6.  
  7. echo '<table>
  8.   <tr>
  9.      <td width="200">'.<img src=\''.$src.'\' '.$reducir.' />.'</td>
  10.       <td>informacion</td>
  11.       <td>informacion</td>
  12.       <td>informacion</td>
  13.    </tr>
  14. </table>';

con esto tus imagenes se ajustaran a tu contenedor de 200px =D

cualquier duda que tengas comenta =D
__________________
Se acepta Karma (:

Si Dios con nosotros, quien contra nosotros !!