I just got introduced to Inkscape and it seems like a pretty cool piece of software. have a very simple task: I have several images that are maps of a certain location. I added the names of the countries to one but I would like to do the exact same thing to 40 similar images - they are exactly the same but different times. Is there some way I can copy this one layer to my other images? Thanks a lot for your help!!!!
After some experimenting, I found a way.
Make a copy of the image with text. Remove everything but the text and take care that the text stays in place. All images to alter have to have the same number of layers, same geometry, size and orientation. Add an additional layer to the image which will be nothing but the text and move the text to the top layer.
Then open a simple text editor and edit that that text containing file. Remove the closing -Tag. Remove everything above the text and the layer preceding it.
My sample file looks like this - depending on font, size, position, text content and so on, your text will look different, but somewhat similar:
and I named it layer2.snippet . I didn't name it layer2.svg, to prevent it from being altered too, later, when iterating over all svg-files.
Make backups from your file, in case something goes wrong.
The aim is now to place this code in every file to be pimped just before the last line, the closing svg-tag.
Some tool to do so is Sed.
If you have Linux or Mac, installing Sed (the Stream EDitor) is a simple task - on Windows Sed is available too and installing is preceeded by searching for it. GNU-Sed is an excellent choice.
If you are into programming, using a different language will comfort you more. Here is a solution in Bash with sed, I hope.
#!/bin/bash # # loop over all existing maps, assuming they are all named *.svg and all files # with such a name shall be altered. for f in *.svg do # get the linenumber of the last line in this file: fln=$(sed -n "$=" "$f") # calculate the line before ln=$((fln-1)) # read the layer2.snippet file in, just in the line before the closing </svg> # sed -i will alter the file $f in place. sed -i "$ln r layer2.snippet" "$f" done
First I tried without layer, positioning the text before the last closing group, but on opening the result, the text had moved vertically up. I don't know why, but had similar experiences before with Inkscape 0.92 - not with the former version 0.48 and didn't dig deeper into the problem.
Instead I tried to move it to the beginning, after the metadata-block, but then it was overlayed by later appearing elements down the file.
Then I thought ImageMagick:composite might do the job, but it converted the SVG into a bitmap, which resulted in the parts below the font being hidden by the space between characters and inside the outline.
The bashcode should work on Linux and Mac, but on Windows, you'll have to know your shell yourself or solve the task in a programming language you prefer.