You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by fireball <sa...@hotmail.com> on 2012/08/17 18:11:33 UTC

Broken image

I am trying to load an svg which has a link to an image. The reslut is a
broken image.

My loading into canvas and the broken image is very similar to 
http://batik.2283329.n4.nabble.com/Broken-image-embedded-PNG-td3962524.html
http://batik.2283329.n4.nabble.com/Broken-image-embedded-PNG-td3962524.html 

Note that the image resides in the same directory where the SVG file is.

My SVG:
<svg
   xmlns="http://www.w3.org/2000/svg"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   version="1.1">
  <g
     id="image"
     transform="matrix(1,0,0,1,0,0)">
     <image width="200" height="180" xlink:href="image.png"/>
  </g>
</svg>



When loaded it becomes:
...
<g id="image" transform="matrix(1, 0, 0, 1, 0,0)">
<image width="200" xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="image.png" xlink:type="simple" xlink:actuate="onLoad"
height="180" preserveAspectRatio="xMidYMid meet" xlink:show="embed"/>
</g>
...

Any thoughts of how to resolve this issue?



--
View this message in context: http://batik.2283329.n4.nabble.com/Broken-image-tp4655209.html
Sent from the Batik - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Broken image

Posted by fireball <sa...@hotmail.com>.
Found solution in case other poeple have the same issue.

Problem - I was loading SVG file as an inputstream and setting uri to null:
document = f.createDocument(null, inputStream);

Solution is to simply set the URI:
document = f.createDocument(file.toURI().toString(), inputStream);

Fireball.



--
View this message in context: http://batik.2283329.n4.nabble.com/Broken-image-tp4655209p4655344.html
Sent from the Batik - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Broken image

Posted by DeWeese Thomas <th...@gmail.com>.
Hi fireball,

	I'm pretty sure that your importer doesn't import the xml:base attribute from the 'svg' element.
So in the new document the 'image' element doesn't have an xml:base to establish the base URL to resolve 'image.png' against.  If you were to move the xml:base down to the 'g' I think it would work.

	Alternately (and probably better in the long run) you could have your importer create a 'g' element and set an xml:base attribute on that that corresponds to the URL of the document it's importing.  If you do that make sure to use 'setAttributeNS' with the 'xml' namespace (it's also best to use xml:base as your name).

	Thomas

On Aug 17, 2012, at 1:53 PM, fireball wrote:

> I tried something like this but it does not work. 
> 
> <svg
>    xmlns="http://www.w3.org/2000/svg"
>    xmlns:xlink="http://www.w3.org/1999/xlink"
>    xml:base="C:/dev/resources/svg"
>    version="1.1">
>   <g
>      id="image"
>      transform="matrix(1,0,0,1,0,0)">
>      <image width="200" height="180" xlink:href="image.png"/>
>   </g>
> </svg>
> 
> Note that this document gets improted to another. I wonder if that has any
> side effects.
> 
> 
> 
> --
> View this message in context: http://batik.2283329.n4.nabble.com/Broken-image-tp4655209p4655211.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Broken image

Posted by fireball <sa...@hotmail.com>.
Hi Jonathan,

I tried something like this but it does not work. 

<svg
    xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xml:base="C:/dev/resources/svg"
    version="1.1">
   <g
      id="image"
      transform="matrix(1,0,0,1,0,0)">
      <image width="200" height="180" xlink:href="image.png"/>
   </g>
 </svg>

Note that this document gets improted to another. I wonder if that has any
side effects.



--
View this message in context: http://batik.2283329.n4.nabble.com/Broken-image-tp4655209p4655211.html
Sent from the Batik - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Broken image

Posted by jonathan wood <jo...@gmail.com>.
Hi fireball,

  You may not be resolving the url properly - You may need to call
SVGOMDocument.setDocumentURI()
or set the xml:base attribute in the svg document.



On Fri, Aug 17, 2012 at 12:11 PM, fireball <sa...@hotmail.com> wrote:

> I am trying to load an svg which has a link to an image. The reslut is a
> broken image.
>
> My loading into canvas and the broken image is very similar to
> http://batik.2283329.n4.nabble.com/Broken-image-embedded-PNG-td3962524.html
> http://batik.2283329.n4.nabble.com/Broken-image-embedded-PNG-td3962524.html
>
> Note that the image resides in the same directory where the SVG file is.
>
> My SVG:
> <svg
>    xmlns="http://www.w3.org/2000/svg"
>    xmlns:xlink="http://www.w3.org/1999/xlink"
>    version="1.1">
>   <g
>      id="image"
>      transform="matrix(1,0,0,1,0,0)">
>      <image width="200" height="180" xlink:href="image.png"/>
>   </g>
> </svg>
>
>
>
> When loaded it becomes:
> ...
> <g id="image" transform="matrix(1, 0, 0, 1, 0,0)">
> <image width="200" xmlns:xlink="http://www.w3.org/1999/xlink"
> xlink:href="image.png" xlink:type="simple" xlink:actuate="onLoad"
> height="180" preserveAspectRatio="xMidYMid meet" xlink:show="embed"/>
> </g>
> ...
>
> Any thoughts of how to resolve this issue?
>
>
>
> --
> View this message in context:
> http://batik.2283329.n4.nabble.com/Broken-image-tp4655209.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>