Ver Mensaje Individual
  #2 (permalink)  
Antiguo 02/10/2011, 04:21
Avatar de KarlanKas
KarlanKas
Moderador extraterrestre
 
Fecha de Ingreso: diciembre-2001
Ubicación: Madrid
Mensajes: 6.987
Antigüedad: 22 años, 4 meses
Puntos: 61
Respuesta: redimensionar imagen a partir de su alto y ancho por defecto

Prueba esto!
Código Javascript:
Ver original
  1. <html>
  2. <head>
  3. <title>Untitled</title>
  4. </head>
  5.  
  6. <body>
  7. <img />
  8. <script>
  9. foto=new Image();
  10. foto.src="http://www.karlankas.net/carnet2.jpg";
  11. document.images[0].src=foto.src;
  12. document.images[0].onload=function(){
  13.     ancho=foto.width;
  14.     alto=foto.height;
  15.     alert("Medidas de la imagen: \n\n"+ancho+"px X "+alto+"px")
  16.     if (alto < ancho){
  17.         document.images[0].style.height = 40 + "%";
  18.     }
  19.     else
  20.     {
  21.         document.images[0].style.height = 20 + "%";  
  22.     }
  23. }
  24. </script>
  25.  
  26. </body>
  27. </html>
__________________
Cómo escribir

No hay pregunta tonta, sino tonto que quiere seguir en la ignorancia.