1

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!!!!

5
  • You could simply copy/paste. Are you seeking some sort of automated process? – Scott Jan 28 '20 at 21:42
  • Scott, I didnt want to copy paste the same names of the countries 40-50 times as well as they all have to be in the same position on the map because I am making a movie loop with those images and if the some of the text is awry in 1-2 then the movie will look weird. Thanks a lot!!! – fatima55 Jan 28 '20 at 22:43
  • Someone told me you can copy paste the same layers which she says is the text in my case. – fatima55 Jan 29 '20 at 0:01
  • 2
    For pasting in the same position, try Ctrl+Alt+V. – Moini Jan 30 '20 at 22:19
  • Have you tried to put each map on a different layer and the text on its layer? Keeping visible just the text layer and one map layer at once should allow you to export each map with the labels. – Paolo Gibellini Oct 27 '20 at 8:14
0

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:

Layer2test

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.