get real image size

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    get real image size

    Hi,

    I wonder, if there is a possibility to determine the real size (width/height) of an image in JavaScript. something like Gecko’s naturalWidth/naturalHeight. in FF/Safari I can get the values, but that doesn’t work for Chrome and Opera.

    Dormi
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    hmmm ... might be that this is of some help?

    kind regards

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      it seems it takes the image dimensions immediately after loading the source and before the styling of the image applies … maybe I can make something of that (but I don’t install jQuery just for that)

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        me too ... wouldn't do that :) ... just thought to show the link as a ref on how to try to achieve that goal ...

        kind regards

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          seems like I don’t get it without jQuery (i.e. test script failed)

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            hmmm ... might be that a xmlhttprequest and php's getimagesize() would be a good idea? this could even be used before sending a page so that a page could include a javascript 'image-info' object? ... seems better than a JavaScript solution?

            kind regards

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              is there anything without requiring a server script? (like a HEAD request …)

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5390

                #8
                none that i'm aware of ... sorry ... didn't even had such a requirement before so there might be possibilities that i just don't know :)

                kind regards

                Comment

                • Dormilich
                  Recognized Expert Expert
                  • Aug 2008
                  • 8694

                  #9
                  darn, were it for the file size, a HEAD Request would be perfect …

                  Comment

                  Working...