<Img> tag, width, height

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • homecurr@yahoo.com

    <Img> tag, width, height

    I am writing a tool to generate html and have a problem with the <img>
    tag. The tool generates something like "<img src="...">". At the time
    the html is generated, the tool does not know the actual image size,
    but I do want to resize any image so that their width and height will
    both be smaller than 100. I also want to keep the iamge width/height
    ration so the image looks "normal". If I use <img src="..." width=100
    height=100> the image will be resized. If I use <img src="..." width =
    100>, it does not work if the height is larger than the width. If I
    define the height, same thing. Is there a way I can do what I want?

    Thanks,

    John
  • Kris

    #2
    Re: &lt;Img&gt; tag, width, height

    In article <2d5d0ce4.04070 20833.640265fd@ posting.google. com>,
    homecurr@yahoo. com wrote:
    [color=blue]
    > I am writing a tool to generate html and have a problem with the <img>
    > tag. The tool generates something like "<img src="...">". At the time
    > the html is generated, the tool does not know the actual image size,
    > but I do want to resize any image so that their width and height will
    > both be smaller than 100. I also want to keep the iamge width/height
    > ration so the image looks "normal". If I use <img src="..." width=100
    > height=100> the image will be resized. If I use <img src="..." width =
    > 100>, it does not work if the height is larger than the width. If I
    > define the height, same thing. Is there a way I can do what I want?[/color]

    I cannot help you. I can only add to your problems: next is the required
    ALT attribute. How will your tool guess the value for that one?

    --
    Kris
    <kristiaan@xs4a ll.netherlands> (nl)

    Comment

    • C A Upsdell

      #3
      Re: &lt;Img&gt; tag, width, height

      <homecurr@yahoo .com> wrote in message
      news:2d5d0ce4.0 407020833.64026 5fd@posting.goo gle.com...[color=blue]
      > I am writing a tool to generate html and have a problem with the <img>
      > tag. The tool generates something like "<img src="...">". At the time
      > the html is generated, the tool does not know the actual image size,
      > but I do want to resize any image so that their width and height will
      > both be smaller than 100. I also want to keep the iamge width/height
      > ration so the image looks "normal". If I use <img src="..." width=100
      > height=100> the image will be resized. If I use <img src="..." width =
      > 100>, it does not work if the height is larger than the width. If I
      > define the height, same thing. Is there a way I can do what I want?[/color]

      If you do not use the real image size, the image will be distorted. Also,
      if the real image is larger than what you specify, the load time will
      increase unnecessarily.

      If you want the image size to be no larger than 100x100, tell your graphics
      designers to design within this restriction.



      Comment

      • Neal

        #4
        Re: &lt;Img&gt; tag, width, height

        On 2 Jul 2004 09:33:50 -0700, <homecurr@yahoo .com> wrote:
        [color=blue]
        > I am writing a tool to generate html and have a problem with the <img>
        > tag. The tool generates something like "<img src="...">". At the time
        > the html is generated, the tool does not know the actual image size,
        > but I do want to resize any image so that their width and height will
        > both be smaller than 100. I also want to keep the iamge width/height
        > ration so the image looks "normal". If I use <img src="..." width=100
        > height=100> the image will be resized. If I use <img src="..." width =
        > 100>, it does not work if the height is larger than the width. If I
        > define the height, same thing. Is there a way I can do what I want?[/color]

        Congratulations , you've discovered one of the reasons resizing in the HTML
        isn't effective! To do what you want, you'll need to have the image
        library gone through and all images with a dimension larger than 100px
        should be reduced.

        Always, always, always serve the images at the right size, don't rely on
        the HTML for that.

        Comment

        • jmm-list-tr

          #5
          Re: &lt;Img&gt; tag, width, height

          homecurr@yahoo. com wrote:[color=blue]
          > I am writing a tool to generate html and have a problem with the <img>
          > tag. The tool generates something like "<img src="...">". At the time
          > the html is generated, the tool does not know the actual image size,[/color]

          Fix your tool to extract the width/height from the image. It is not
          rocket science; the specs for gif/png/jpeg/tiff are public domain. Then
          just use either width or height attribute to force the image to resize
          proportionately .
          As others have mentioned, though, downloading a large image and using
          HTML to reduce it is wasteful. If the source of the images cannot be
          convinced to reduce the images, have your tool do it. After all, what good
          is a tool that only does half the job?
          A final note: Providing correct width/height info makes the browser's
          job of rendering easier since it knows how much space to allow for the
          image. This reduces the problem of a page constantly changing size as it
          is loaded.

          --
          jmm dash list at sohnen-moe dot com
          (Remove .TRSPAMTR for email)

          Comment

          • cruiserweight

            #6
            Re: &lt;Img&gt; tag, width, height

            homecurr@yahoo. com wrote in message news:<2d5d0ce4. 0407020833.6402 65fd@posting.go ogle.com>...[color=blue]
            > I am writing a tool to generate html and have a problem with the <img>
            > tag. The tool generates something like "<img src="...">". At the time
            > the html is generated, the tool does not know the actual image size,
            > but I do want to resize any image so that their width and height will
            > both be smaller than 100. I also want to keep the iamge width/height
            > ration so the image looks "normal". If I use <img src="..." width=100
            > height=100> the image will be resized. If I use <img src="..." width =
            > 100>, it does not work if the height is larger than the width. If I
            > define the height, same thing. Is there a way I can do what I want?
            >
            > Thanks,
            >
            > John[/color]

            if you are "writing a tool to generate html" then you probably have
            the skills to use PHP and getImageSize(). It will solve you problems
            as fast as you can type

            $theSize = getImageSize($m yImage);
            echo "$theSize[3]";

            Comment

            Working...