Posted By

philokezzar on 05/24/09


Tagged

javascript resize image textmate


Versions (?)

Javascript dynamic image resizing


 / Published in: Other
 

  1. function ResizeImage(image, maxwidth, maxheight)
  2. {
  3. if (image.className == "Thumbnail")
  4. {
  5. w = image.width;
  6. h = image.height;
  7.  
  8. if( w == 0 || h == 0 )
  9. {
  10. image.width = maxwidth;
  11. image.height = maxheight;
  12. }
  13. else if (w > h)
  14. {
  15. if (w > maxwidth) image.width = maxwidth;
  16. }
  17. else
  18. {
  19. if (h > maxheight) image.height = maxheight;
  20. }
  21.  
  22. image.className = "ScaledThumbnail";
  23. }
  24. }

Report this snippet  

You need to login to post a comment.