SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Apr 2010
    Posts
    263
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Shrink and move image to an absolute position

    I know that I can shrink and move a div but am having problems shrinking an image and keeping the proportions correct. Can anyone help with advice or a website link?

  2. #2
    Non-Member
    Join Date
    Jul 2012
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's fairly straight forward.

    Load the image into an Image object and then you can get the image's actual dimensions in pixels using the object's width and height properties. Then calculate the image's aspect ratio (width/height), Set the new height or width in pixels and then calculate the other dimension using the aspect ratio. This way you can set the image dimensions to whatever you like and still maintain the image's aspect ratio.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •