mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
[手动选题][tech]: 20230304.2 ⭐️⭐️ Create templates for your video graphics with Inkscape.md
This commit is contained in:
parent
63a2e7157a
commit
f249bc5edf
@ -0,0 +1,165 @@
|
|||||||
|
[#]: subject: "Create templates for your video graphics with Inkscape"
|
||||||
|
[#]: via: "https://opensource.com/article/23/3/video-templates-inkscape"
|
||||||
|
[#]: author: "Máirín Duffy https://opensource.com/users/mairin"
|
||||||
|
[#]: collector: "lkxed"
|
||||||
|
[#]: translator: " "
|
||||||
|
[#]: reviewer: " "
|
||||||
|
[#]: publisher: " "
|
||||||
|
[#]: url: " "
|
||||||
|
|
||||||
|
Create templates for your video graphics with Inkscape
|
||||||
|
======
|
||||||
|
|
||||||
|
Recently, I recorded a [15-minute tutorial][1] with supporting materials on how to automate graphics production in [Inkscape][2]. I demonstrated this by building a base template and automatically replacing various text strings in the file from a CSV using the [Next Generator Inkscape extension][3] by Maren Hachmann. In case you'd rather read instead of watching a video, you can read the accompanying article [How I automate graphics creation with Inkscape][4] here on Opensource.com.
|
||||||
|
|
||||||
|
Based on popular demand from that tutorial, I created a more advanced tutorial that expands upon the last one. It demonstrates how to automate image replacement and changing colors using the same method.
|
||||||
|
|
||||||
|
You can watch it on the [Fedora Design Team Linux Rocks PeerTube channel][5] or the embedded YouTube video below:
|
||||||
|
|
||||||
|
![YouTube Video][5]
|
||||||
|
|
||||||
|
In this article, I provide some context for how this tutorial is useful. I also include a very high-level summary of the content in the video in case you'd rather skim text and not watch a video.
|
||||||
|
|
||||||
|
### Conference talk card graphics
|
||||||
|
|
||||||
|
The background on this tutorial is continued from the original tutorial. For each Flock/Nest conference, you need a graphic for each talk for the online platform used to host the virtual conference. There's usually 50 or more talks for large events. That's a lot of graphics to produce manually.
|
||||||
|
|
||||||
|
With this tutorial, you learn how to make a template like this in Inkscape:
|
||||||
|
|
||||||
|
![Image of an Inkscape template.][7]
|
||||||
|
|
||||||
|
And a CSV file like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
ConferenceName, TalkName, 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 combine them to generate one graphic per row in the CSV, where the background color of the slide, the background color of the track name, the speaker headshot background, and the speaker headshot image change accordingly:
|
||||||
|
|
||||||
|
![Image of a combined CSV and Inkscape template.][8]
|
||||||
|
|
||||||
|
There are many things you can use this technique for. You can use it to create consistent cover images for your channel videos. You can even use it to create awesome banners and graphics for Fedora as a member of the [Fedora Design Team][9]!
|
||||||
|
|
||||||
|
### Install the Inkscape Next Generator extension
|
||||||
|
|
||||||
|
The first step to creating these is to install [the Next Generator extension][3] for Inkscape created by Maren Hachmann:
|
||||||
|
|
||||||
|
- Go to the website and download the [next_gen.inx][10] and [next_gen.py][11] from the top level of the repo.
|
||||||
|
- Then go into the **Edit > Preferences > System** dialog in Inkscape. Search for the **User Extensions** directory listing and click the **Open** icon next to it. Drag the .inx and .py files into that folder.
|
||||||
|
- Finally, you should close all open Inkscape windows and restart Inkscape. The new extension is under the **Extensions** menu: **Extensions > Export > Next Generator**.
|
||||||
|
|
||||||
|
### Create the template
|
||||||
|
|
||||||
|
Each header of your CSV file (in my example: ConferenceName, TalkName, PresenterNames) is a variable you can place in an Inkscape file that serves as your template. Take a look at the [example SVG template file][12] for directions. If you want the TalkName to appear in your template, create a text object in Inkscape and put the following content into it:
|
||||||
|
|
||||||
|
```
|
||||||
|
%VAR_TalkName%
|
||||||
|
```
|
||||||
|
|
||||||
|
When you run the extension, the _%VAR_TalkName%_ text is replaced with the _TalkName_ listed for each row of the CSV. So for the first row, _%VAR_TalkName%_ is replaced with the text _The Pandas Are Marching_ for the first graphic. For the second graphic, the _TalkName_ is _Why Fedora is the Best Linux_. You continue doing this until you get to the _TalkName_ column for each graphic.
|
||||||
|
|
||||||
|
### Extend the template for color changes
|
||||||
|
|
||||||
|
There's not much you have to do for color changes except decide what colors you want to change. You can come up with field names for them in your CSV, and pick out colors for each row of your CSV. In my example CSV, there are two colors of the background gradient that change (BackgroundColor1 and BackgroundColor2) and an accent color (AccentColor) that is used to color the conference track name background lozenge as well as the outline on the speaker headshot:
|
||||||
|
|
||||||
|
```
|
||||||
|
BackgroundColor1, BackgroundColor2, AccentColor
|
||||||
|
51a2da, ,294172 ,e59728
|
||||||
|
afda51, ,0d76c4 ,79db32
|
||||||
|
9551da, ,130dc4 ,a07cbc
|
||||||
|
da51aa, ,e1767c ,db3279
|
||||||
|
```
|
||||||
|
|
||||||
|
### Change only certain items of the same color
|
||||||
|
|
||||||
|
There is one trick you have to do if you have the same color you want to change in some parts of the image and to stay the same in other parts of the image.
|
||||||
|
|
||||||
|
The way color changes work in Next Generator is a simple find and replace type of mechanism. So when you tell Next Generator in Inkscape to replace anything with the color code **#ff0000** (which is in the sample template and what I like to call obnoxious red) to some other color (let's say **#aaaa00**), it will replace every single object in the file that has **#ff0000** as a color to the new value, **#aaaa00**.
|
||||||
|
|
||||||
|
If you want just the conference track name background's red to change color, but you want to keep the color border around the speaker's headshot red in all of the graphics, there's a little trick you can use to achieve this. Simply use the HSV tool in the **Fill and Stroke** dialog in Inkscape to tune the red item that you didn't want down just one notch. If you change it **#fa0000**, it has a different hex value for its color code. Then, you can have anything with **#ff0000** change color according to the values in your CSV. Anything **#fa0000** would stay red and be unaffected by the color replacement mechanism.
|
||||||
|
|
||||||
|
Now a couple of things to note about color codes:
|
||||||
|
|
||||||
|
- Do not use **#** in the CSV or the JSON (more on the JSON below) for these color values.
|
||||||
|
- Only use the first six "digits" of the hex color code. Inkscape by default includes 8, the last two are the alpha channel/opacity value for the color. (But wait, how do you use different opacity color values here then? You might be able to use an inline stylesheet that changes the **fill-opacity** value for the items you want transparency on, but I have not tested this yet.)
|
||||||
|
|
||||||
|
### Extending the template for image changes
|
||||||
|
|
||||||
|
First, you want to add "filler" images to your template. Do this by linking them. Do not embed them when you import them into Inkscape. I embedded one in the template – photo.png.
|
||||||
|
|
||||||
|
Then, prep the CSV for the color changes and for the image changes. You need to come up with field names for any images you want to be swapped in your CSV. You can list the image filenames you want to replace in each row of your CSV. In the example CSV, you have just one image with a field name of "Photo":
|
||||||
|
|
||||||
|
```
|
||||||
|
Photo
|
||||||
|
beefy.png
|
||||||
|
colur.png
|
||||||
|
panda.png
|
||||||
|
badger.png
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that the images as listed in the CSV are just filenames. I recommend placing these files in the same directory as your template SVG file. Then you won't have to worry about specifying specific file paths. This makes your template more portable ([tar][13] or zip it up and share).
|
||||||
|
|
||||||
|
### Build the JSON for the Next Generator dialog
|
||||||
|
|
||||||
|
The final (and trickiest) bit of getting this all to work is to write some JSON formatted key-value pairs for Next Generator. This helps it understand which colors and images are present in the template file map and which field names and column headers are in your CSV file, so it knows what goes where.
|
||||||
|
|
||||||
|
Here is the example JSON I used:
|
||||||
|
|
||||||
|
```
|
||||||
|
{"BackgroundColor1":"51a2da","BackgroundColor2":"294172","AccentColor":"ff0000","Photo":"photo.png"}
|
||||||
|
```
|
||||||
|
|
||||||
|
Where did I come up with those color codes for the JSON? They are all picked from the **template.svg** file. The color code **51a2da** is the lighter blue color in the circular gradient in the background and **294172** is the darker blue towards the bottom of the gradient. The color code **ff0000** (obnoxious red) is the color border around the speaker headshot and the background lozenge color behind the track name.
|
||||||
|
|
||||||
|
Where did the **photo.png** filename come from? That's the name of the filler image I used for the headshot placement. If you're in Inkscape and not sure what the filename of the image you're using is, right click, select **Image Properties** and it's the value in the URL field pops up in the sidebar.
|
||||||
|
|
||||||
|
### Run the Generator
|
||||||
|
|
||||||
|
Once your template is ready, simply run the Next Generator extension by loading your CSV into it. Select which variables (header names) you want to use in each file name, and copy paste your JSON snippet into the dialog in the **Non-text values to replace** field:
|
||||||
|
|
||||||
|
![Image of what fields to select in Next Generator.][14]
|
||||||
|
|
||||||
|
Hit apply and enjoy!
|
||||||
|
|
||||||
|
### Troubleshoot color and image replacement issues
|
||||||
|
|
||||||
|
I leave you with some hard-won knowledge on how to troubleshoot when color and/or image replacement is not working:
|
||||||
|
|
||||||
|
- Image names are just the filename. Keep the images in the same directory as your template. You do not need to use the full file path. (This will make your templates more portable since you can tar or zip up the directory and share it.)
|
||||||
|
- Image names, color values, and variable names in the spreadsheet _do not_ need any " or ' unless you need to escape a comma (,) character in a text field. Image names, color values, and variable names always need quotes in the JSON.
|
||||||
|
- The # character does not precede color values. It won't work if you add it.
|
||||||
|
- By default, Inkscape gives you an 8-digit hex value for color codes. The last two correspond to the alpha value of the color (ff0000ff for bright red with no opacity.) You will need to remove the last two digits so you are using the base 6-“digit” hex code for the color values (that correspond to RGB colors) to remove the opacity/alpha values from the color code. Otherwise, the color replacement won't work.
|
||||||
|
- Check that you have all variable names in the JSON written exactly the same as in the CSV header entries except with " in the JSON (BackgroundColor1 in the CSV is "BackgroundColor1" in the JSON.)
|
||||||
|
- Use the filename for the default image you are replacing in the template. You do not use the ObjectID or any other Inkscape-specific identifier for the image. Also, link the image instead of embedding it.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://opensource.com/article/23/3/video-templates-inkscape
|
||||||
|
|
||||||
|
作者:[Máirín Duffy][a]
|
||||||
|
选题:[lkxed][b]
|
||||||
|
译者:[译者ID](https://github.com/译者ID)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]: https://opensource.com/users/mairin
|
||||||
|
[b]: https://github.com/lkxed/
|
||||||
|
[1]: https://blog.linuxgrrl.com/2022/07/19/how-to-automate-graphics-production-with-inkscape/
|
||||||
|
[2]: http://inkscape.org
|
||||||
|
[3]: https://gitlab.com/Moini/nextgenerator
|
||||||
|
[4]: https://opensource.com/article/23/3/automate-graphics-production-inkscape
|
||||||
|
[5]: https://peertube.linuxrocks.online/w/cwMFobUNJehm2QDN6NJeES
|
||||||
|
[6]: https://www.youtube.com/embed/984Kz1_8dGQ
|
||||||
|
[7]: https://opensource.com/sites/default/files/2023-02/Template_Example_Inkscape.png
|
||||||
|
[8]: https://opensource.com/sites/default/files/2023-02/Compined%20-template-andCSV.png
|
||||||
|
[9]: https://matrix.to/#/#design:fedoraproject.org
|
||||||
|
[10]: https://gitlab.com/Moini/nextgenerator/-/raw/master/next_gen.inx?inline=false
|
||||||
|
[11]: https://gitlab.com/Moini/nextgenerator/-/raw/master/next_gen.py?inline=false
|
||||||
|
[12]: https://gitlab.com/fedora/design/team/tutorials/inkscape-automation/-/blob/main/template-simple.svg
|
||||||
|
[13]: https://opensource.com/article/22/8/linux-tar-command
|
||||||
|
[14]: https://opensource.com/sites/default/files/2023-02/NextGeneratorScreenshot.what%20fields.png
|
Loading…
Reference in New Issue
Block a user