How call an image file to use into SVG image element?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chengenfang
    New Member
    • Jun 2011
    • 5

    How call an image file to use into SVG image element?

    I want to open a local image file in my local PC, such as "E:\image\a.jpg ", then I write the code as following:
    <svg>
    <image xlink:herf="E:\ image\a.jpg" x="100" y="100" height="500" width="600">
    </svg>

    but the image don't show in my IE,how call a local image file to use the SVG image element?

    Thank you very much.
    Good night.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    A ".jpg" contains information about pixels and colours to render (show) the image.

    An SVG file contains math formulas that tell the software that is rendering the image how to recreate actual objects that show the image.


    Here is some documentation on the SVG document structure.

    -Frinny
    Last edited by Frinavale; Jun 14 '11, 02:01 PM.

    Comment

    • chengenfang
      New Member
      • Jun 2011
      • 5

      #3
      Pls tell me how to display an image in IE by SVG <image ? >.
      thanks.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        The following code uses an <object> element to load the SVG file from the server.

        If it fails to load, the browser will display the content between the opening and closing object tags.

        Code:
        <!DOCTYPE html>     
        <html xmlns="http://www.w3.org/1999/xhtml">     
          <head>
            <title>SVG Example</title>
          </head>
          <body>
         
            <object type="image/svg+xml" data="mySvgFile.svg">
              <img src="myPicture.png" alt="my picture"/>  
            </object>
        
          </body>
        </html>
        Here is my "mySvgFile.svg" :
        Code:
        <?xml version="1.0" standalone="no"?>
        <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
        "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
        
        <svg width="100%" height="100%" version="1.1"
        xmlns="http://www.w3.org/2000/svg">
        
        <circle cx="100" cy="50" r="40" stroke="black"
        stroke-width="2" fill="yellow"/>
        
        </svg>
        Last edited by Frinavale; Jun 13 '11, 04:12 PM.

        Comment

        • chengenfang
          New Member
          • Jun 2011
          • 5

          #5
          my code is :

          Code:
          <?xml version="1.0"?>
          <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
            " http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
          <svg  >
              
          <image xlink:href="c:\1.jpg" type="image/jpeg" x="20" y="20" width="100" heithg="100"/>
          
          </svg>
          but the image "1.jpg" don't display in IE,why?
          Last edited by Niheel; Jun 15 '11, 12:17 AM.

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            What version of Internet Explorer are you using?

            Comment

            • chengenfang
              New Member
              • Jun 2011
              • 5

              #7
              The version of my IE is 8.0.6

              The version of my IE is 8.0.6, I feel unsure about why it don't display,thank you very much.
              Best wish.

              Comment

              • Frinavale
                Recognized Expert Expert
                • Oct 2006
                • 9749

                #8
                I may be wrong but I believe you need IE9 for this to work. I don't think that IE8 supports SVGs.
                Last edited by Frinavale; Jun 14 '11, 02:56 PM.

                Comment

                • drhowarddrfine
                  Recognized Expert Expert
                  • Sep 2006
                  • 7434

                  #9
                  Frinny is correct. Modern browsers have always been able to render SVG. IE9 finally does, though poorly.

                  Comment

                  • chengenfang
                    New Member
                    • Jun 2011
                    • 5

                    #10
                    Thank you very much!

                    the rect and text in the following code all can display by my IE 8.0.6,but the image don't display, why?


                    Code:
                    <?xml version="1.0"?>
                    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
                      " http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
                    <svg xmlns=" http://www.w3.org/2000/svg">
                      <rect x="100" y="10" width="200" height="100" fill="green" />
                      <text x="92" y="400" font-size="80" fill="black">SVG Example</text>
                      <image xlink:href="c:\1.jpg" type="image/jpeg" x="50" y="300" width="200" heithg="600" />
                    </svg>

                    My browser may be the cause of the problem, what browser are you used now?

                    Regards,

                    Comment

                    • drhowarddrfine
                      Recognized Expert Expert
                      • Sep 2006
                      • 7434

                      #11
                      xlink support is poor in all browsers and I doubt IE is better but I don't recall. Since IE didn't even support xhtml at all till recently, I question if there is any today. iirc, Firefox and Opera only supported simple links.

                      Comment

                      Working...