PDA

View Full Version : SVG to Raster



Jeff_Wilson63
10-07-2009, 03:30 PM
I'm loving svg. Unfortunately svg images can't be read by IE or posted to this forum so I need something to change svg into a raster image. Because of what I want to do, I'd prefer an application that will automatically handle linked svg files.

My searches have turned up Apache Batik. Does anyone have experience with this program and know whether it handles linked svg files?

Failing Batik, does anyone know of another product that can import linked svg files (Inkscape and GIMP don't, by the way) and export a raster image?

As last recourse I can write a php program to bring the files together so Inkscape or GIMP can read them, but that seems file bloat to no real purpose, so I'd prefer to avoid it.

torstan
10-07-2009, 03:47 PM
Imagemagick should be able to do it:

convert test.svg test.png

should work? It certainly says that it can handle svg.

Redrobes
10-07-2009, 04:32 PM
Yes I believe IM can do it. But hold on a mo. Why not use Firefox, Opera, IE, or Safari ? I was under the impression that proper web browsers could view them directly.

Now theres something wrong with that line...Oh yes... proper web browsers. Yeah so Firefox, Opera, or Safari - try any of them and it ought to display. :twisted:

Jeff_Wilson63
10-07-2009, 04:54 PM
so Firefox, Opera, or Safari - try any of them and it ought to display.
Yep. I'm using Firefox to test my images, and when I rewrite my pages I'll use svg directly. However, you can't post svg images to this forum. Since I'll need the conversion to post to this forum anyway, I might was well set things up to allow IE users to view svg images I want to show.

Another factor is the several hundred png files that already exist vs. the couple of thousand references to those files. Replacing the png's may be easier than rewriting the web pages to use svg files. (Though the rewrite will still need to be done eventually I know.)

ravenx99
10-07-2009, 05:42 PM
Inkscape handles linked SVG files just fine... it just doesn't provide a friendly interface for creating the links. So if you already have a bunch of SVG files that just need converted, Inkscape should handle that. If you want to create new SVG files, you can do it with Inkscape, but you have to edit the links in the XML editor by hand. Kind of a pain if you're wanting to do a bunch of map symbols or something.

For map symbols, it turned out to be more beneficial to build my library of SVG symbols and write a script to convert them all to PNGs to use in my maps. That way, Inkscape doesn't have to re-render the blurs on all the imported objects, which speeds up the display considerably.

Jeff_Wilson63
10-08-2009, 07:05 PM
Inkscape handles linked SVG files just fine... it just doesn't provide a friendly interface for creating the links. So if you already have a bunch of SVG files that just need converted, Inkscape should handle that. If you want to create new SVG files, you can do it with Inkscape, but you have to edit the links in the XML editor by hand. Kind of a pain if you're wanting to do a bunch of map symbols or something.
Er, what? This doesn't match what Inkscape does at all.

http://www.monticello21st.com/glyphica/GlySymList.svg loads fine in both Inkscape and Firefox because there are no linked files. http://www.monticello21st.com/glyphica/GlyGrpList.svg displays just fine in Firefox, but displays an empy box on loading in Inkscape. The only syntactical difference between the two files is that the second uses linked files and first doesn't.

I have no need to use Inkscape's built-in XML editor as the link data is already included in the files I'm trying to convert.

Hai-Etlik
10-08-2009, 07:33 PM
I think there's some confusion in terminology. The OP seems to be using "link" to mean use elements with external references. Other people are interpreting it as the use element in general, or as hyperlinks.

Inkscape supports the use element with references to internally defined elements.

Firefox supports the use element with references to externally defined elements.

Inkscape has a fairly basic interface for creating hyperlinks from elements. It doesn't provide any mechanism for following them.

Firefox supports following such hyperlinks the same way it does HTML hyperlinks.

Jeff_Wilson63
10-08-2009, 09:05 PM
Yes. Thank you.

I need a graphics convertor that will handle svg files which use externally defined elements.

I do use <map><area> in html code to define image maps and hadn't considered actually putting those commands (or the xml equivalent) into the svg file itself to create hyperlinks. I'll have to look at that when I reach that point.

ravenx99
10-09-2009, 03:06 AM
Er, what? This doesn't match what Inkscape does at all.

Er, just trying to help.

Inkscape does exactly what I said it does... it includes and renders linked SVG files. But it doesn't support referencing individual objects inside the file with ID #anchors, which is what your sample file requires. That is, Inkscape can use "image xlink:href=file" to include an SVG file, but it can't do "use xlink:href=file#id" to reference specific objects.

So Inkscape does what you said it can't. But what you said it can't do isn't what you needed it to do. So stop looking at me like I'm smoking an illegal substance. :)

Too bad Inkscape doesn't support this... it'd be a nice feature for maintaining symbol libraries. I have to keep a separate SVG file for each map symbol.

Jeff_Wilson63
10-09-2009, 04:40 PM
That is, Inkscape can use "image xlink:href=file" to include an SVG file, but it can't do "use xlink:href=file#id" to reference specific objects.
OK. I see how this works now. Thanks for the information.

After some thought it's still easier for me to use php to generate temporary files than to break my existing files down to their separate symbols. I'll post if I find any alternatives.

Hai-Etlik
10-10-2009, 01:09 AM
You could post a feature request to the Inkscape bug tracker.

0.47 is too close so it probably wouldn't make it in for this cycle but it would probably make 0.48

Jeff_Wilson63
10-10-2009, 02:26 AM
There already is one. Apparently it's a very difficult problem and isn't on the schedule to be fixed at all. Finding that was why I was so confident that Inkscape didn't do what I wanted and why I was so confused by the statement that it did.

Jeff_Wilson63
10-10-2009, 08:23 PM
FYI. It doesn't look like ImageMagick even handles internally linked elements. My svg files are totally trashed when I try to load them.

Batik, however, works fine. Here's a translation of Tolkien's "One Ring" in my conlang using moderately large symbols:

http://www.monticello21st.com/glyphica/GlyGrpList.png

One ring to rule them all,
One ring to find them,
One ring to bring them all,
And in the darkness bind them.

Batik is a command line program, which does present a few hassles, but otherwise seems to do what I want. Once I build the svg display files I can easily batch convert them to png.