Results 1 to 5 of 5

Thread: resize an image by a percentage of itself?

  1. #1
    Join Date
    Oct 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default resize an image by a percentage of itself?

    i specifically say "percentage of itself" because by default,

    width=50%

    ...will make it 50% of the browser window.

    what i really want to do is make an image thinner. don't ask why. will this be possible?

    thank you.

  2. #2
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    thinner??

    say you have a table and the tables width is 100(width=100) and inside that table you habe a image and inside that img tag you have 50%(img src="" width=50%) but when you see this in plain veiw it will show half of what the table is... understand..
    example..
    table=100
    img width=50%
    divided=the width will equal 50
    another example....
    table=240
    imd width=20%
    divided=the width will equal 12

    same with height...
    I hope this is what you want..
    Hey new design new look, goto xudas for personal webdsign help.. (:

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Well, there's no way to make it a percent of itself with a simple number.

    Just do some math on the dimensions.

    You could use Javascript or PHP to generate this dynamically, but it would be a good bit of work.

    something like
    image.width = image.width/2;
    But that would mean you have already set image as that element on the page.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Oct 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    actually, i think i might have something working. i was going to try something with tables awhile ago, but figured it wouldn't work.

    not so skilled with either js or php, and i don't want to use any fixed numbers as i'm going to be using this for multiple pages for different sized images.

    like i was saying, i think i have something working with tables. if you don't set table width or height, it'll default to whatever the original image dimensions are. then within the img tag, denote the width and height (in percent), and it'll make it a percent of what the table is. the table won't "shrink" to the newly resized image or anything.

    did not realize this would work, but it does.

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    ImageMagick:
    Code:
    prompt$ convert -sample 50%x100% image.png image-thin.png
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •