Resize an image to fit a CSS without knowing if it is portrait orlandscape shape

Discussion in 'HTML' started by zorro, Jul 6, 2007.

  1. zorro

    zorro Guest

    Hello,
    I have a square shaped CSS and I would like to resize a picture to fit
    it. The problem is that I do not know if it is a portrait or landscape
    shape picture, so I do not know whether it is the height or the width
    that must be resize to 100% of the CSS. Obviously, I would like to keep
    the aspect ratio of the original picture.
    Is it possible to do what I want?
    Thank you
    David L.
     
    zorro, Jul 6, 2007
    #1
    1. Advertising

  2. Re: Resize an image to fit a CSS without knowing if it is portrait or landscape shape

    Scripsit zorro:

    > I have a square shaped CSS


    Really? Sounds like a mauve database. But you could have compensated for the
    absurdity of the problem description by specifying the URL of your page.
    After all, if we can see the page, we can often figure out what the problem
    is.

    > and I would like to resize a picture to fit it.


    Oh.

    > The problem is that I do not know if it is a portrait or landscape
    > shape picture, so I do not know whether it is the height or the width
    > that must be resize to 100% of the CSS.


    Probably "square shaped CSS" means an HTML element, probably a div element,
    for which you suggest height and width properties with the same value, in
    CSS. And now you apparently want to use CSS to scale an image, with
    arbitrary intrinsic dimensions, so that it fits into the square occupied by
    the element and is as large as possible, within those limits.

    The simple answer is that you cannot do that in CSS.

    Why do you want to make browsers scale an image in the first place? Old
    browsers used to scale very poorly, and hardly any browser scales better
    than an average image processing program. So why don't you just do the
    scaling server-side?

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Jul 6, 2007
    #2
    1. Advertising

  3. zorro

    zorro Guest

    Re: Resize an image to fit a CSS without knowing if it is portraitor landscape shape

    Even if you seem to be bored by this question (perhaps because as a
    French, I do not speak your language as well as I should to post on this
    forum), you understand acurately my problem and give me the answer: "you
    cannot do that in CSS".
    The reason why I would like to do this is that thanks to some JS code,
    the CSS is dynamically resized and moved.
    And the reason why I do not know if this is landscape or portrait shaped
    is that the pictures are listed from a directory with PHP before, so
    that I can add pictures in the directory and make them be taken into
    account without needing modifying the code. I am going to see if PHP can
    get access to the header of the jpg and get the width and height of the
    picture.
    Thanks for your time...
    David L.


    Jukka K. Korpela a écrit :
    > Scripsit zorro:
    >
    >> I have a square shaped CSS

    >
    > Really? Sounds like a mauve database. But you could have compensated for
    > the absurdity of the problem description by specifying the URL of your
    > page. After all, if we can see the page, we can often figure out what
    > the problem is.
    >
    >> and I would like to resize a picture to fit it.

    >
    > Oh.
    >
    >> The problem is that I do not know if it is a portrait or landscape
    >> shape picture, so I do not know whether it is the height or the width
    >> that must be resize to 100% of the CSS.

    >
    > Probably "square shaped CSS" means an HTML element, probably a div
    > element, for which you suggest height and width properties with the same
    > value, in CSS. And now you apparently want to use CSS to scale an image,
    > with arbitrary intrinsic dimensions, so that it fits into the square
    > occupied by the element and is as large as possible, within those limits.
    >
    > The simple answer is that you cannot do that in CSS.
    >
    > Why do you want to make browsers scale an image in the first place? Old
    > browsers used to scale very poorly, and hardly any browser scales better
    > than an average image processing program. So why don't you just do the
    > scaling server-side?
    >
     
    zorro, Jul 6, 2007
    #3
  4. Re: Resize an image to fit a CSS without knowing if it is portrait or landscape shape

    Gazing into my crystal ball I observed zorro <> writing in
    news:468e7c48$0$19901$:

    > I am going to see if PHP can
    > get access to the header of the jpg and get the width and height of the
    > picture.
    >


    Yes, it can. The PHP manual has all the details. Oh, and next time,
    please don't top post.

    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne Boswell, Jul 6, 2007
    #4
  5. zorro

    zorro Guest

    Re: Resize an image to fit a CSS without knowing if it is portraitor landscape shape

    Adrienne Boswell a écrit :
    > Gazing into my crystal ball I observed zorro <> writing in
    > news:468e7c48$0$19901$:
    >
    >> I am going to see if PHP can
    >> get access to the header of the jpg and get the width and height of the
    >> picture.
    >>

    >
    > Yes, it can. The PHP manual has all the details. Oh, and next time,
    > please don't top post.
    >

    Ok sorry and thak you
     
    zorro, Jul 6, 2007
    #5
  6. Re: Resize an image to fit a CSS without knowing if it is portrait or landscape shape

    Adrienne Boswell <> writes:

    > Gazing into my crystal ball I observed zorro <> writing in
    > news:468e7c48$0$19901$:
    >
    >> I am going to see if PHP can
    >> get access to the header of the jpg and get the width and height of the
    >> picture.

    >
    > Yes, it can.


    With the appropriate options enabled, it can also resize the images on the
    server, either when they're uploaded or when they're served to visitors. As
    Jukka said, that's a *far* better option than relying on the browser to do
    the resizing.

    sherm--

    --
    Web Hosting by West Virginians, for West Virginians: http://wv-www.net
    Cocoa programming in Perl: http://camelbones.sourceforge.net
     
    Sherm Pendley, Jul 6, 2007
    #6
  7. zorro

    zorro Guest

    Re: Resize an image to fit a CSS without knowing if it is portraitor landscape shape

    Sherm Pendley a écrit :
    > Adrienne Boswell <> writes:
    >
    >> Gazing into my crystal ball I observed zorro <> writing in
    >> news:468e7c48$0$19901$:
    >>
    >>> I am going to see if PHP can
    >>> get access to the header of the jpg and get the width and height of the
    >>> picture.

    >> Yes, it can.

    >
    > With the appropriate options enabled, it can also resize the images on the
    > server, either when they're uploaded or when they're served to visitors. As
    > Jukka said, that's a *far* better option than relying on the browser to do
    > the resizing.
    >
    > sherm--
    >

    You mean, as the images are frequently resized, make PHP resize and not JS?
     
    zorro, Jul 6, 2007
    #7
  8. Re: Resize an image to fit a CSS without knowing if it is portrait or landscape shape

    zorro <> writes:

    > Sherm Pendley a écrit :
    >> Adrienne Boswell <> writes:
    >>
    >>> Gazing into my crystal ball I observed zorro <>
    >>> writing in news:468e7c48$0$19901$:
    >>>
    >>>> I am going to see if PHP can get access to the header of the jpg
    >>>> and get the width and height of the picture.
    >>> Yes, it can.

    >>
    >> With the appropriate options enabled, it can also resize the images on the
    >> server, either when they're uploaded or when they're served to visitors. As
    >> Jukka said, that's a *far* better option than relying on the browser to do
    >> the resizing.
    >>

    > You mean, as the images are frequently resized, make PHP resize and not JS?


    No, I mean you should do that with PHP because browsers do a horrible job of
    it for some reason. Also, there's no reason your users should have to wait
    for a full-size 100Kb download, when all they're really going to see is a
    little thumbnail that could have been delivered in a fraction of the time.

    sherm--

    --
    Web Hosting by West Virginians, for West Virginians: http://wv-www.net
    Cocoa programming in Perl: http://camelbones.sourceforge.net
     
    Sherm Pendley, Jul 6, 2007
    #8
  9. zorro

    zorro Guest

    Re: Resize an image to fit a CSS without knowing if it is portraitor landscape shape

    Sherm Pendley a écrit :
    > zorro <> writes:
    >
    >> Sherm Pendley a écrit :
    >>> Adrienne Boswell <> writes:
    >>>
    >>>> Gazing into my crystal ball I observed zorro <>
    >>>> writing in news:468e7c48$0$19901$:
    >>>>
    >>>>> I am going to see if PHP can get access to the header of the jpg
    >>>>> and get the width and height of the picture.
    >>>> Yes, it can.
    >>> With the appropriate options enabled, it can also resize the images on the
    >>> server, either when they're uploaded or when they're served to visitors. As
    >>> Jukka said, that's a *far* better option than relying on the browser to do
    >>> the resizing.
    >>>

    >> You mean, as the images are frequently resized, make PHP resize and not JS?

    >
    > No, I mean you should do that with PHP because browsers do a horrible job of
    > it for some reason. Also, there's no reason your users should have to wait
    > for a full-size 100Kb download, when all they're really going to see is a
    > little thumbnail that could have been delivered in a fraction of the time.
    >
    > sherm--
    >


    Thanks for all the details.
    David L.
     
    zorro, Jul 6, 2007
    #9
  10. zorro

    Neredbojias Guest

    Re: Resize an image to fit a CSS without knowing if it is portrait or landscape shape

    On Fri, 06 Jul 2007 19:40:37 GMT Sherm Pendley scribed:

    >> You mean, as the images are frequently resized, make PHP resize and
    >> not JS?

    >
    > No, I mean you should do that with PHP because browsers do a horrible
    > job of it for some reason.


    Opera does _that_ very well. It's true, though, that browsers in-the-main
    are a backwards, decrepit lot which should be much better than they are.
    This is probably because there's no money in them.

    --
    Neredbojias

    Q: Do you speak Turkish?
    A: Gobble gobble, dude.
     
    Neredbojias, Jul 6, 2007
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Piet
    Replies:
    0
    Views:
    598
  2. active
    Replies:
    15
    Views:
    789
    active
    Jun 27, 2007
  3. Mark Shroyer

    Portrait of a "real life" __metaclass__

    Mark Shroyer, Nov 10, 2007, in forum: Python
    Replies:
    5
    Views:
    294
    Mark Shroyer
    Nov 11, 2007
  4. John Butler
    Replies:
    3
    Views:
    219
    Axel Etzold
    Sep 14, 2007
  5. xdzgor

    print - portrait or landscape

    xdzgor, Aug 24, 2009, in forum: Javascript
    Replies:
    9
    Views:
    296
    Thomas 'PointedEars' Lahn
    Aug 27, 2009
Loading...

Share This Page