How to convert Inkscape SVG to PlainSVG and PNG

by Rick on September 17th, 2009

I’m working on a project at the moment, that has a number of design and asset files I’ve created in Inkscape, and of course saved in Inkscape’s SVG format. The only problem is this is a somewhat ‘bloated’ format as it has extra information from SodiPodi and Inkscape embedded in it which increases file size, and makes it more difficult to traverse the XML.

I also need to convert these SVGs to PNG for including in the Design Document; and for art assets inclusion in the final product.

I tried playing around with ImageMagick, but it didn’t handle fonts as nicely as I’d have liked. There are ways to reconfigure it to look for the fonts, but I didn’t want to bother with that for now. Inkscape already displays it how I need, so I might as well use it for the whole process.

The simplest way to convert from InkscapeSVG to PlainSVG on the command line is: inkscape --export-plain-svg=OUTFILE INFILE

Note that if you name it the same thing you’ll risk killing your existing file. It’ll still load in Inkscape in theory, but some special things may be lost. Your mileage may vary.

To PNG, again, we can use the same command structure. inkscape --export-png=OUTFILE INFILE
Note that with PNG export, you’re going to have a transparent background by default. While you’re drawing on the canvas its default is white, however there is no actual data there, so it saves to a transparency. In this case I needed to have everything output with a white background. You can add the flag --export-background=ffffffff to get a white background. Replace the hex with any other html colour code for the equivalent background.

I put this all together in a script to let me do a bunch of files all at once. It needs some more tweaking for options like transparency on/off, checking for update times to avoid excess workload, etc; but it works fine for my needs. You may find it useful too. It creates two folders in the current folder: plainsvg and png. This keeps it neat and tidy. It’ll go over every .svg in the directory and convert and save. Note this has rename -f in use, which will clobber any existing files with the same name.


#!/bin/sh
# (C) 2009 Richard Cuddy
# Feel free to use this however you want, if you do something seriously awesome with it, let me know!

mkdir plainsvg
mkdir png

find . -name "*.svg" -type f -exec inkscape --export-plain-svg={}.tmp {} \;

mv *.svg.tmp plainsvg
cd plainsvg

find . -name "*.svg.tmp" -type f -exec rename -v -f 's/\.svg\.tmp/\.svg/' {} \;

find . -name "*.svg" -type f -exec inkscape --export-background=ffffffff --export-png={}.png {} \;
find . -name "*.svg.png" -type f -exec rename -v -f 's/\.svg\.png/\.png/' {} \;

mv *.png ../png/

Related Posts:

How to use SVG to create easily changeable desktop backgrounds in Ubuntu.

by Rick on September 7th, 2009

I was wanting to leave myself a set of to do notes on my desktop the other day, so that I could see them after I woke up the next morning. I’ve done this a few times before, by editing the original image and saving out a new one.

I decided I wanted to make it look a bit less terrible by using Inkscape instead of the Gimp. For quick rectangles and text, Inkscape really is faster and looks better. As I was editing it, I wondered if it would be possible to use the SVG itself as a background image.

I opened up the Appearance settings, and browsed for the file. What do you know, it showed up. This in and of itself isn’t that exciting, until you realise that SVG can be changed really easily in a script. It’s just XML data. What can be interesting is that you can embed a link to a non SVG image to use an underlay. I didn’t have to duplicate my 600kb JPG, I was able to just embed that link, and then add text and paths on top of it.

What’s more exciting was that as soon as I saved any changes, the background image automatically refreshed itself. Something I was never able to make Windows XP do easily, without making an actual call to Windows’ DLL system. This was just edit, save, bam.

The possibilities are quite interesting. I may later put together some bash or python to do something fun like updating the BG with system internals, getting currently playing music, etc. Really you could do anything with this. All without damaging your original image or mucking around with graphics blitting code.

The only things to be aware of is that when you save in Inkscape, it defaults to an SVG format with a -lot- of extra information which makes the file more confusing than it needs to be. Just remember to save it as “Plain SVG” if you’re doing this. Also, the image link must be a full path. A relative link doesn’t work correctly, and Gnome can’t display the image. For example:
<image
xlink:href="/home/username/images/backgrounds/mypic.jpg"
x="0"
y="0"
width="1680"
height="1050"
id="image11" />

When it originally saved, it only saved as xlink:href=”mypic.jpg” If you’re doing future editing only in a script by changing the XML directly, you shouldn’t have to worry about this after you change it once.

Related Posts:

Do you want a great source of books, with free world wide shipping?

by Rick on September 7th, 2009

People who know me will know that I love to buy books. People in Australia who know me will also know that I (as many others do) lament the high cost of books here. Sometimes it is cheaper to find them online than to buy them locally. The first stop for most people is to go to Amazon. Everyone knows them, and they have a vast assortment of items. The problem with Amazon if you’re overseas and in a country with no local Amazon website, is that you must pay absolutely painful shipping rates. This can end up eating most of the savings you’d hope to have by going online in the first place.

Thankfully, a friend of mine recommended The Book Depository. While it’s a UK based site, they have a brilliant feature that makes me want to go with them for my book needs now. They have free shipping, worldwide. That’s right. Zero cost for delivery. You only pay for the book, which the prices are RRP/MSRP or slightly lower. Not bad at all.

Case in point. I wanted to buy two books yesterday.”Alan Moore’s Writing for Comics” and “The DC Comics Guide to Writing Comics”. While Amazon had DC’s guide for USD$14.93, and The Book Depository has it for USD$21.87. TBD had “Writing for Comics” for about USD$0.60 cheaper than, Amazon, so no real major difference. The total cost however was USD$27.22 for both books from TBD, and almost $36 after shipping from Amazon.

If you’re in the US, maybe it won’t matter so much to you. Regardless, you’ll still be paying some shipping; I think TBD is will worth considering when you next buy your books.

For those interested:

“Alan Moore’s Writing for Comics” @ TBD | Amazon
“The DC Comics Guide to Writing Comics” @ TBD | Amazon

Related Posts:

  • No Related Posts

The week after Freeplay

by Rick on August 19th, 2009

This weekend was Freeplay, as some of you may know. For those not in the know, its a yearly Indie Games Festival held to showcase the latest projects, share information and knowledge, and help boost the general sense of Independent Game Development.

Unfortunately due to time constraints I only attended the last part of Friday’s events, and I was ill (my own doing) on Saturday and managed to completely miss the entire day. So what do I have to say that’s worth reading, since I wasn’t there for most of it? Not a lot. Just that the two sessions I managed to go to were absolutely awesome and inspiring.

Firstly, I managed to attend The art of getting things done presented by Rory Hart. For a session on Project Management, I think a lot of us were surprised by the number of people who turned up. The room was packed. It was a good session and started the seed idea of “Just Do It.” This is a problem I think a lot of us face. We have GREAT IDEAS™ which we never actually do anything with, or we dawdle about and occasionally poke at them hoping it’ll get us somewhere eventually. A truth I’m reminded of more often lately is that ideas are absolutely worthless without execution. If it’s stuck in your head, no one actually cares how great it is. Solution? Stop wasting time. I am interested in something he said along the lines of “if you haven’t worked on it for a week or more, move on, you’re not passionate enough about that idea.” (Paraphrased)

Which leads us in to the next speaker, Petri Purho. He is the brilliant man who created Crayon Physics Deluxe. What did he have to talk about? Making Shit Games. That’s right. Making crappy, ugly little prototype games to get your ideas out of your head, and into a testable and playable demo. He makes a new game prototype every month. He only spends 7 days on the process though. This allows a lot of GREAT IDEAS™ to actually be made real, so you can see that they’re horrible ideas, and no one would ever play them. But, as pointed out: it’s better to only spend seven days on a worthless idea, than two years.

I think the inspiration of those two sessions and speakers alone was worth the $20 I paid to get for the weekend. I’m seriously looking at my ideas, my skills, and my tools and I think I will begin a project much like he and the Experimental Gameplay Project (I believe they actually started the first 7day prototyping projects). I’ll spend the next week or so getting to terms with Flex/AS3 and SDL/C++ and see if I can’t start cranking out some shitty games. One a month, at least one of them has to be worth something, right?

Related Posts:

  • No Related Posts

Free Template to Help Your Web Designs

by Rick on June 28th, 2009

One of the early steps of any web site design is to do mock-ups and sketches of the layout before you begin doing any HTML and CSS. Pen and Paper is still definitely a valid method for this, but as we move along ever more digital it can be nice to merge the two.

(more…)

Related Posts:

  • No Related Posts

Working from Home Away from Home

by Rick on May 30th, 2009

Working from Home. It’s such an appealing concept. You can choose when to wake up, when to go to bed, when and how much work you want to get done each day, and you don’t even have to get dressed or leave the house.

If you’ve a strict personality and can easily keep yourself focused, this is great. If you don’t however, you’ll quickly fall into a trap of too much of the “from home” and not enough of the working. I have one of those artist personalities that means I’d prefer to sleep till 2 in the afternoon instead of getting up at a “sensible” time, and then it takes me till 4am before I feel like doing any of that “work” stuff.

This is hardly useful for getting work done. Keeping a schedule and a routine doesn’t mean you have to revert to the 9-5 schedule and wear a tie every day.

If you’re like me, you may need to take the work away from home to get it done. I find it amazing how easily I can focus my efforts and get tasks completed by taking it outside. The following is a list of places I tend to work from home away from home.
(more…)

Related Posts:

  • No Related Posts

Want versus Will

by Rick on May 21st, 2009

The words we use can have an amazing impact on our ways of thinking and our actions. Something you’re often told when dealing with anxiety is that you should focus less on “need” and “should” and more on “want to” and “can”.

It shouldn’t stop there however. Wanting something will certainly put you closer to a mindset of success and doing, but its unfortunately been changed from a definite (Need, Should) to a potential (Want to). This is dangerous for some, because you’ve allowed yourself an out. “I want to write a novel by the end of the year.” This sounds good, and is definitely a step up from “I should stop wasting so much time, and do something productive this year” but you’ve still left yourself an indefinite target. If you fail to write the novel, it doesn’t really matter, because it wasn’t something you’d really committed yourself to doing.

“I will write a novel by the end of the year.” This statement is much more powerful. It puts you in the mind of need, but by going through want as an in between you’ve now got your brain in the state of definite achievement. Not managing to write it in a year is now a failure. You have more at stake, so you will be more likely to achieve the task.

This is something I have a problem with myself. I am full of ideas, and constantly going “I need to do this” or “I want to do this” but I seldom get anything done with this mindset. I resent the need, and I want to do to many things so I have no time to do them all. This puts me in a very bad place as I feel that I’m overwhelmed and helpless. But lately I’ve begun changing the way I’m thinking about things, and it’s helping to drive a focus, and get the “shoulds” done as a side effect of the “wills”.

For example, I want to go back to University next year. I’ve been wanting to do that for a few years now, but something always comes up and there’s a reason why I just can’t right now. But its okay, because one day I will! Tomorrow never comes, unfortunately. I decided that I will go to University next year. Just changing from want to will has already seen me focusing on “needs and shoulds” I’ve been putting off. I’ve booked for my Australian Citizenship exam for instance. I’ll need to get this done before I go to University, so I will do it. Two years of “later” was resolved in a couple of days of phone calls and making a time line.

On a related note, the negatives we use will have just as strong an impact. “I don’t want to work at my current job anymore.” I said that for four years. Why did I never leave? Because I was constantly saying “don’t”. This negative was focusing me entirely on my current job. So this led me to stay there. Sure I applied for other jobs, I looked around sometimes, but the focus was wrong. Once I started thinking “I want to work in a different field,” and then “I will work in a different field” I was able to realise I wasn’t actually trapped, and instead I was capable of moving on and I in fact would succeed. Soon thereafter I was able to work at the best job I’ve ever had. I was actually upset the first Monday after my contract was up that I couldn’t go back in to the office! What a strange concept, and all from changing my mental state.

I was given a task once, to go and during the next week turn 3 things I “should” be doing into 3 things I “wanted” to be doing. You find you have more options all of a sudden when considering what you might want to do instead. Of course, “I want to sit at home watching TV all day” is not a good solution for “I need to go to work.” Again, even with these wants defined, I still needed to do them. I seldom did, but am endeavoring to catch up to this now by changing the want to the next step, will.

Give it a try yourself. During the next week, turn your “I should” into an “I want to”, and then follow up with “I will.” See how much more you achieve.

Related Posts:

  • No Related Posts

Wealth Building – 21st Century Academy

by Rick on May 14th, 2009

A while back I was in a particularly bad place mentally and financially. I was trying to figure out what the point of my day to day existence was, while working at a job I despised with all my being. Then Google fed me a link to website with a free E-Book to download, and a free DVD to request. It was from a group calling themselves 21st Century Academy and dealt with Wealth Building and Asset Creation, and all the usual things that scams use to bait you. I looked and couldn’t find any point that they asked for anything which would require financial commitment from me, so I figured “why not” and downloaded the E Book. Free is free, and I love collecting PDFs, it’s a strange hobby, but there you go.

(more…)

Related Posts:

  • No Related Posts

LWJGL in Netbeans 6.5

by Rick on April 14th, 2009

The Lightweight Java Game Library (LWJGL) is a powerful library for Java Games development, bringing various cross platform libraries for graphics, sound, and input together into a single API. You can see all it can do and find documentation and examples at lwjgl.org.

This is a quick guide on getting it up and running in Netbeans 6.5. I’ll assume you already have Netbeans and Java installed on your system.

(more…)

Related Posts:

  • No Related Posts

555 Blender Tutorials

by Rick on April 13th, 2009

FilmmakerIQ.com has put together the best collection of Blender3D tutorials from the web that I’ve seen.  Covering animation, modeling, texturing, particles and pretty much every thing else you could need, they’ve gathered numerous links to resources from around the web including Blender.org, BlenderNation, and several amazing video tutorials from You Tube users.

This is definitely a list to keep in mind. It is sorted by Site->Topic->Skill Level so you may have to search around a bit if you’re looking for a particular topic as it may be in any one of those sites.

555 Blender Tutorials at FilmmakerIQ.com

Related Posts:

  • No Related Posts