tag or attribut for correct Image-size

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

    #1

    tag or attribut for correct Image-size

    Hi all,

    I have a php-generated webpage with images. My problem is: the Internet
    Explorer cannot calculate the correct image size. Because of this the
    images are not cached. So everytime a user clicks on some link all the
    images gets retransfered and the page loads very slow.
    You can check it if you right-click on an image and select properties.

    Is there a possibility to send the image and its actual
    size-information to the browser?

    I hope this is somehow clear.

    thanks in advance
    Klaus

  • dorayme

    #2
    Re: tag or attribut for correct Image-size

    In article
    <1157951204.393 012.90290@b28g2 000cwb.googlegr oups.com>,
    "klausklausenat or@googlemail.c om"
    <klausklausenat or@googlemail.c omwrote:
    Hi all,
    >
    I have a php-generated webpage with images. My problem is: the Internet
    Explorer cannot calculate the correct image size. Because of this the
    images are not cached. So everytime a user clicks on some link all the
    images gets retransfered and the page loads very slow.
    You can check it if you right-click on an image and select properties.
    >
    Is there a possibility to send the image and its actual
    size-information to the browser?
    >
    I hope this is somehow clear.
    If you are using PHP, then you should know above average stuff
    about HTML (PHP being something a bit more sophisticated server
    side control) like that in the mark up for images, the width and
    height attributes are quite important and are best specified
    exactly. It sounds like your PHP is not properly serving up the
    HTML. Browsers are not great image editors and it is best to tell
    the browser the exact width and height. In general.

    --
    dorayme

    Comment

    • Jukka K. Korpela

      #3
      Re: tag or attribut for correct Image-size

      klausklausenato r@googlemail.co m <klausklausenat or@googlemail.c omscripsit:
      I have a php-generated webpage with images.
      Do you have a URL for it?
      My problem is: the
      Internet Explorer cannot calculate the correct image size.
      Our problem is that we cannot see your real problem since you did not
      specify the URL and did not explain why you think that Internet Explorer
      cannot calculate the correct image size.
      Because of this the images are not cached.
      And what makes you think so? I see little reason to expect image size to
      have anything to do with cacheing, which operates on "entities" referred to
      by URLs (btw, did I mention that you didn't mention the URL of your page?),
      _not_ to their specific content, still less rendering.
      So everytime a user clicks on some
      link all the images gets retransfered and the page loads very slow.
      Is there any reason to think that the images are "the same" as images that
      have already been fetched by the browser? Cacheing works by URLs and HTTP
      headers, not content. So if you have the same image accessible through
      different URLs*), they are not the same from the cacheing perspective. Image
      sizes have nothing to do with this.

      *) "URL" here means the resolved absolute URL, which may differ from the
      URLs in the src="..." attributes.
      You can check it if you right-click on an image and select properties.
      I cannot, because you did not specify any URL and you did not say what is
      the "it" that I could check.
      Is there a possibility to send the image and its actual
      size-information to the browser?
      Yes, that's what servers do all the time.
      I hope this is somehow clear.
      It isn't. It would be somewhat obscure even with a URL, but without a URL...

      --
      Jukka K. Korpela ("Yucca")


      Comment

      • Rik

        #4
        Re: tag or attribut for correct Image-size

        klausklausenato r@googlemail.co m wrote:
        Hi all,
        >
        I have a php-generated webpage with images. My problem is: the
        Internet Explorer cannot calculate the correct image size. Because of
        this the images are not cached. So everytime a user clicks on some
        link all the images gets retransfered and the page loads very slow.
        You can check it if you right-click on an image and select properties.
        I wouldn't know ether this is the problem.
        Is there a possibility to send the image and its actual
        size-information to the browser?
        ob_start();
        imagejpeg(); //(/...png()/...gif())
        header('Content-type: image/jpeg');
        header('Content-length: '.ob_get_length ());
        ob_flush();

        Grtz,
        --
        Rik Wasmus


        Comment

        • Jerry Stuckle

          #5
          Re: tag or attribut for correct Image-size

          klausklausenato r@googlemail.co m wrote:
          Hi all,
          >
          I have a php-generated webpage with images. My problem is: the Internet
          Explorer cannot calculate the correct image size. Because of this the
          images are not cached. So everytime a user clicks on some link all the
          images gets retransfered and the page loads very slow.
          You can check it if you right-click on an image and select properties.
          >
          Is there a possibility to send the image and its actual
          size-information to the browser?
          >
          I hope this is somehow clear.
          >
          thanks in advance
          Klaus
          >
          You mean such as:

          <img src="/images/image1.gif" width=150 height="200" alt="My Image">

          Straight html - nothing to do with PHP.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • Andy Dingley

            #6
            Re: tag or attribut for correct Image-size

            dorayme wrote:
            My problem is: the Internet
            Explorer cannot calculate the correct image size.
            Is there a possibility to send the image and its actual
            size-information to the browser?
            If you are using PHP, then you should know above average stuff
            about HTML
            Not certain about this, but AFAIR the IE image non-caching problem is
            related to file size, not image size. It's _not_ a HTML problem and you
            can't solve it by using the <img width... height... attributes. So
            it's a HTTP problem, not a HTML problem.

            _AFAIR_ (you should probably check this, as it's years since I hit
            this problem)
            IE doesn't cache things it doesn't know the storage size of. For images
            it finds this from a HTTP header which is sent before the image data.
            If your image is dynamically generated, then you won't know the size
            until it has been generated. If you code in the easy and obvious
            manner, you omit the header and just start writing image data back as
            fast as you create it. IE manages to display this, but it won't cache
            it.

            The fix is to generate it on the server as a PHP variable, find the
            size of it, write the size back in a HTTP header, then write the image
            data in the HTTP response.

            Comment

            • Greg N.

              #7
              Re: tag or attribut for correct Image-size

              Jukka K. Korpela wrote:
              >I hope this is somehow clear.
              It isn't. It would be somewhat obscure even with a URL, but without a
              URL...
              You need to add WIDTH and HEIGHT attributes to your <IMGtags. If you
              generate your html through PHP, you'll need to code something like this:

              $myimage="myfol der\mypic.jpg";
              $size = getimagesize($m yimage);
              $width = $size[0];
              $height = $size[1];
              echo "<img src=$myimage width=$width height=$height> ";

              I have not tested this code snippet, but you get the idea. It requires
              the function getimagesize() (which is not part of the PHP core, but
              pretty common these days) to be available on your server.

              --
              Gregor mit dem Motorrad auf Reisen:

              Comment

              • Chuck Anderson

                #8
                Re: tag or attribut for correct Image-size

                Greg N. wrote:
                Jukka K. Korpela wrote:
                >
                >
                >>I hope this is somehow clear.
                >>>
                >
                >
                >It isn't. It would be somewhat obscure even with a URL, but without a
                >URL...
                >>
                >
                You need to add WIDTH and HEIGHT attributes to your <IMGtags. If you
                generate your html through PHP, you'll need to code something like this:
                >
                $myimage="myfol der\mypic.jpg";
                $size = getimagesize($m yimage);
                $width = $size[0];
                $height = $size[1];
                echo "
                >
                >
                >
                There is also a nice shortcut:

                <img src=$myimage $size[3]>";


                getimagesize ... "Returns an array with 4 elements ...
                .... Index 3 is a text string with the correct height="yyy" width="xxx"
                string that can be used directly in an IMG tag."

                --
                *************** **************
                Chuck Anderson • Boulder, CO

                *************** **************

                Comment

                • Jukka K. Korpela

                  #9
                  Re: tag or attribut for correct Image-size

                  Greg N. <yodel_dodel@ya hoo.comscripsit :
                  Jukka K. Korpela wrote:
                  >
                  >>I hope this is somehow clear.
                  >
                  >It isn't. It would be somewhat obscure even with a URL, but without a
                  >URL...
                  >
                  You need to add WIDTH and HEIGHT attributes to your <IMGtags.
                  No I don't. You seem to have no idea of I what I wrote in my message, and
                  you quoted something that you don't comment on.

                  And your message has nothing to do with the problem posed, though it seems
                  to involve a misconception that the original poster also had.

                  --
                  Jukka K. Korpela ("Yucca")


                  Comment

                  • klausklausenator@googlemail.com

                    #10
                    Re: tag or attribut for correct Image-size

                    Thanks everyone for trying to answer my question.

                    The solution (for me) lies not in using the height and width attribute
                    in the <src>-Tag, because my problem had to do something with the file
                    size and not with the image size. Sorry for the confusion.

                    The solution was to send an special header before the actual picture.
                    So now I use something like this:

                    <?php
                    ob_start();
                    header("Expires : " . date("D, j M Y H:i:s", time() + (86400 * 7)) . "
                    UTC");
                    header("Cache-Control: Public");
                    header("Pragma: Public");
                    $im = imagecreatefrom gif($src);
                    imagegif($im);
                    header('Content-type: image/gif');
                    header('Content-length: ' . ob_get_length() );
                    ob_flush();
                    ?>

                    And it was an IE caching problem. Now it works pretty well. Special
                    thanks goes to Andy Dingley and Rik.

                    Klaus

                    Comment

                    Working...