The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Image scaling by %?

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #188465

    Hi guys.

    I am making an image gallery and I need to create thumbnails of each image.
    However, each image may be a different size and I want my users to be able to select the thumbnail size based on a % of the original image.
    The users will choose a % that the thumbnail will be.

    The question is what is the math I need to use to scale various images by a given % the user selects?

    For example one image may be 1920 wide x 1080 height.
    How do I calculate this so the thumbnail is 10% of this?

    It wouldn’t be as simple as multiplying each value by 10% would it?
    Isn’t that an image much smaller than 10% of the original?

    Another image may be a 5k image:
    How do I calculate a thumbnail for this of 5%, and 10%?

    Thanks for your help.


    Your right, for 10% simply multiply the width and the height by .1, 5% would be .05, etc.

    You don’t even have to do the calculations manually just slap percentages on the img tag through CSS.

    img {
    width: 10%;

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Other’ is closed to new topics and replies.