Science and technology

Create templates on your video graphics with Inkscape

Recently, I recorded a 15-minute tutorial with supporting supplies on easy methods to automate graphics manufacturing in Inkscape. I demonstrated this by constructing a base template and routinely changing varied textual content strings within the file from a CSV utilizing the Next Generator Inkscape extension by Maren Hachmann. In case you’d somewhat learn as a substitute of watching a video, you may learn the accompanying article How I automate graphics creation with Inkscape right here on Opensource.com.

Based on in style demand from that tutorial, I created a extra superior tutorial that expands upon the final one. It demonstrates easy methods to automate picture substitute and altering colours utilizing the identical technique.

You can watch it on the Fedora Design Team Linux Rocks PeerTube channel or the embedded YouTube video under:
 

In this text, I present some context for a way this tutorial is helpful. I additionally embrace a really high-level abstract of the content material within the video in case you’d somewhat skim textual content and never watch a video.

Conference speak card graphics

The background on this tutorial is sustained from the unique tutorial. For every Flock/Nest convention, you want a graphic for every speak for the net platform used to host the digital convention. There’s often 50 or extra talks for giant occasions. That’s lots of graphics to provide manually.

With this tutorial, you learn to make a template like this in Inkscape:

(Máirín Duffy, CC BY-SA 4.0)

And a CSV file like this:

ConferenceIdentify, TalkIdentify, PresenterNames, TrackNames, BackgroundColor1, BackgroundColor2, AccentColor, Photo
BestCon, The Pandas Are Marching, Beefy D. Miracle, Exercise, 51a2da, 294172, e59728, beefy.png
Fedora Nest, Why Fedora is the Best Linux, Colúr and Badger, The Best Things, afda51, 0d76c4, 79db32, colur.png
BambooFest 2022, Bamboo Tastes Better with Fedora, Panda, Panda Life, 9551da, 130dc4, a07cbc, panda.png
AwesomeCon, The Best Talk You Ever Heard, Dr. Ver E. Awesome, Hyperbole, da51aa, e1767c, db3279, badger.png

You can mix them to generate one graphic per row within the CSV, the place the background colour of the slide, the background colour of the monitor identify, the speaker headshot background, and the speaker headshot picture change accordingly:

(Máirín Duffy, CC BY-SA 4.0)

There are many issues you need to use this method for. You can use it to create constant cowl pictures on your channel movies. You may even use it to create superior banners and graphics for Fedora as a member of the Fedora Design Team!

Install the Inkscape Next Generator extension

The first step to creating these is to put in the Next Generator extension for Inkscape created by Maren Hachmann:

  1. Go to the web site and obtain the next_gen.inx and next_gen.py from the highest stage of the repo.
  2. Then go into the Edit > Preferences > System dialog in Inkscape. Search for the User Extensions listing itemizing and click on the Open icon subsequent to it. Drag the .inx and .py recordsdata into that folder.
  3. Finally, you need to shut all open Inkscape home windows and restart Inkscape. The new extension is below the Extensions menu: Extensions > Export > Next Generator.

Create the template

Each header of your CSV file (in my instance: ConferenceIdentify, TalkIdentify, PresenterNames) is a variable you may place in an Inkscape file that serves as your template. Take a take a look at the example SVG template file for instructions. If you need the TalkIdentify to look in your template, create a textual content object in Inkscape and put the next content material into it:

%VAR_TalkIdentify%

When you run the extension, the %VAR_TalkIdentify% textual content is changed with the TalkIdentify listed for every row of the CSV. So for the primary row, %VAR_TalkIdentify% is changed with the textual content The Pandas Are Marching for the primary graphic. For the second graphic, the TalkIdentify is Why Fedora is the Best Linux. You proceed doing this till you get to the TalkIdentify column for every graphic.

Extend the template for colour adjustments

There’s not a lot it’s important to do for colour adjustments besides determine what colours you wish to change. You can provide you with area names for them in your CSV, and pick colours for every row of your CSV. In my instance CSV, there are two colours of the background gradient that change (BackgroundColor1 and BackgroundColor2) and an accent colour (AccentColor) that’s used to paint the convention monitor identify background lozenge in addition to the define on the speaker headshot:

BackgroundColor1, BackgroundColor2, AccentColor
51a2da, 	         ,294172 	     ,e59728
afda51, 	         ,0d76c4 	     ,79db32
9551da, 	         ,130dc4 	     ,a07cbc
da51aa, 	         ,e1767c 	     ,db3279

Change solely sure gadgets of the identical colour

There is one trick it’s important to do in case you have the identical colour you wish to change in some components of the picture and to remain the identical in different components of the picture.

The means colour adjustments work in Next Generator is an easy discover and exchange kind of mechanism. So whenever you inform Next Generator in Inkscape to interchange something with the colour code #ff0000 (which is within the pattern template and what I wish to name obnoxious crimson) to another colour (as an instance #aaaa00), it’ll exchange each single object within the file that has #ff0000 as a colour to the brand new worth, #aaaa00.

If you need simply the convention monitor identify background’s crimson to vary colour, however you wish to preserve the colour border across the speaker’s headshot crimson in the entire graphics, there’s slightly trick you need to use to attain this. Simply use the HSV device within the Fill and Stroke dialog in Inkscape to tune the crimson merchandise that you simply did not need down only one notch. If you modify it #fa0000, it has a special hex worth for its colour code. Then, you may have something with #ff0000 change colour based on the values in your CSV. Anything #fa0000 would keep crimson and be unaffected by the colour substitute mechanism.

Now a few issues to notice about colour codes:

  • Do not use # within the CSV or the JSON (extra on the JSON under) for these colour values.
  • Only use the primary six “digits” of the hex colour code. Inkscape by default contains 8, the final two are the alpha channel/opacity worth for the colour. (But wait, how do you utilize completely different opacity colour values right here then? You would possibly be capable of use an inline stylesheet that adjustments the fill-opacity worth for the gadgets you need transparency on, however I’ve not examined this but.)

Extending the template for picture adjustments

First, you wish to add “filler” pictures to your template. Do this by linking them. Do not embed them whenever you import them into Inkscape. I embedded one within the template – photograph.png.

Then, prep the CSV for the colour adjustments and for the picture adjustments. You must provide you with area names for any pictures you wish to be swapped in your CSV. You can listing the picture filenames you wish to exchange in every row of your CSV. In the instance CSV, you’ve gotten only one picture with a area identify of “Photo”:

Photo
beefy.png
colur.png
panda.png
badger.png

Note that the photographs as listed within the CSV are simply filenames. I like to recommend inserting these recordsdata in the identical listing as your template SVG file. Then you will not have to fret about specifying particular file paths. This makes your template extra moveable (tar or zip it up and share).

Build the JSON for the Next Generator dialog

The last (and trickiest) little bit of getting this all to work is to write down some JSON formatted key-value pairs for Next Generator. This helps it perceive which colours and pictures are current within the template file map and which area names and column headers are in your CSV file, so it is aware of what goes the place.

Here is the instance JSON I used:

{"BackgroundColor1":"51a2da","BackgroundColor2":"294172","AccentColor":"ff0000","Photo":"photo.png"}

Where did I provide you with these colour codes for the JSON? They are all picked from the template.svg file. The colour code 51a2da is the lighter blue colour within the round gradient within the background and  294172 is the darker blue in the direction of the underside of the gradient. The colour code ff0000 (obnoxious crimson) is the colour border across the speaker headshot and the background lozenge colour behind the monitor identify.

Where did the photograph.png filename come from? That’s the identify of the filler picture I used for the headshot placement. If you are in Inkscape and undecided what the filename of the picture you are utilizing is, proper click on, choose Image Properties and it is the worth within the URL area pops up within the sidebar.

Run the Generator

Once your template is prepared, merely run the Next Generator extension by loading your CSV into it. Select which variables (header names) you wish to use in every file identify, and duplicate paste your JSON snippet into the dialog within the Non-text values to interchange area:

(Máirín Duffy, CC BY-SA 4.0)

Open multimedia and artwork assets

Hit apply and revel in!

Troubleshoot colour and picture substitute points

I go away you with some hard-won data on easy methods to troubleshoot when colour and/or picture substitute is just not working:

  • Image names are simply the filename. Keep the photographs in the identical listing as your template. You don’t want to make use of the total file path. (This will make your templates extra moveable since you may tar or zip up the listing and share it.)
  • Image names, colour values, and variable names within the spreadsheet don’t want any ” or ‘ until it’s worthwhile to escape a comma (,) character in a textual content area. Image names, colour values, and variable names at all times want quotes within the JSON.
  • The # character doesn’t precede colour values. It will not work when you add it.
  • By default, Inkscape offers you an 8-digit hex worth for colour codes. The final two correspond to the alpha worth of the colour (ff0000ff for shiny crimson with no opacity.) You might want to take away the final two digits so you might be utilizing the bottom 6-“digit” hex code for the colour values (that correspond to RGB colours) to take away the opacity/alpha values from the colour code. Otherwise, the colour substitute will not work.
  • Check that you’ve got all variable names within the JSON written precisely the identical as within the CSV header entries besides with ” in the JSON (BackgroundColor1 in the CSV is “BackgroundColor1” within the JSON.)
  • Use the filename for the default picture you might be changing within the template. You don’t use the ObjectID or some other Inkscape-specific identifier for the picture. Also, hyperlink the picture as a substitute of embedding it.

Most Popular

To Top