[手动选题][tech]: 20230303.1 ️ How I automate graphics creation with Inkscape.md

This commit is contained in:
六开箱 2023-03-03 19:36:25 +08:00
parent 63a2e7157a
commit 764448be53

View File

@ -0,0 +1,94 @@
[#]: subject: "How I automate graphics creation with Inkscape"
[#]: via: "https://opensource.com/article/23/3/automate-graphics-production-inkscape"
[#]: author: "Máirín Duffy https://opensource.com/users/mairin"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
How I automate graphics creation with Inkscape
======
I recorded a [15-minute long tutorial][1] demonstrating how to automate the production of graphics from a CSV file or spreadsheet (basically a mailmerge type deal for graphics) in [Inkscape][2]. It uses the [Next Generator Inkscape extension][3] from Maren Hachmann.
You can watch it on the [Fedora Design Team Linux Rocks PeerTube channel][4] (PeerTube is open source!) or the embedded YouTube video below:
![][4a]
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
Each Flock/Nest needs a graphic for each talk for the online platform you use to host a virtual conference. There are usually about 50 or more talks for large events like this. That's a lot of graphics to produce manually.
With this tutorial, you learn how to make a template like this in Inkscape:
![Image showing an example of an Inkscape template.][5]
And a CSV file like this:
| CONFERENCENAME | TALKNAME | PRESENTERNAMES |
| :- | :- | :- |
| BestCon | The Pandas Are Marching | Beefy D. Miracle |
| Fedora Nest | Why Fedora is the Best Linux | Colúr and Badger |
| BambooFest 2022 | Bamboo Tastes Better with Fedora | Panda |
| AwesomeCon | The Best Talk You Ever Heard | Dr. Ver E. Awesome |
Combine them to generate one graphic per row in the CSV, like so:
![Image displaying a CSV on an Inkscape template.][6]
Conference graphics are a good example of how you can apply this tutorial. You could also use it to generate business cards (it outputs a PDF), personalized birthday invitations, personalized graphics for students in your classroom (like student name cards for their desks), and signage for your office. You can use it to create graphics for labeling items, too. You can even use it to create awesome banners and graphics for Fedora [as a member of the Fedora Design Team][7]! There are a ton of possibilities for how you can apply this technique, so let your imagination soar.
### The Inkscape Next Generator extension
The first step to create these images is to install [the Next Generator extension][3] for Inkscape created by Maren Hachmann:
- Go to the website and download the [next_gen.inx][8]and [next_gen.py][9] 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. 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 a 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][10] 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.
### Run the generator
Once your template is ready, run the Next Generator extension by loading your CSV. Then, select which variables (header names) you want to use in each file name and hit the **Apply** button.
In a future article, I will provide a tutorial on more advanced use of this extension, like changing colors and graphics included in each file.
_This article was originally published on the author's [blog][11] and has been republished with permission._
--------------------------------------------------------------------------------
via: https://opensource.com/article/23/3/automate-graphics-production-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://peertube.linuxrocks.online/w/sf8Vqgg3aRkPKpb7KMsHgH
[2]: http://inkscape.org
[3]: https://gitlab.com/Moini/nextgenerator
[4]: https://peertube.linuxrocks.online/c/fedora_design/videos
[4a]: https://youtu.be/IxZC4gNwFyM
[5]: https://opensource.com/sites/default/files/2023-02/InkscapeTemplateExample.png
[6]: https://opensource.com/sites/default/files/2023-02/Bamboo-Tastes-Better-with-FedoraINKSCAPE.png
[7]: https://matrix.to/#/#design:fedoraproject.org
[8]: https://gitlab.com/Moini/nextgenerator/-/raw/master/next_gen.inx?inline=false
[9]: https://gitlab.com/Moini/nextgenerator/-/raw/master/next_gen.py?inline=false
[10]: https://gitlab.com/fedora/design/team/tutorials/inkscape-automation/-/blob/main/template-simple.svg
[11]: https://blog.linuxgrrl.com/2022/07/19/how-to-automate-graphics-production-with-inkscape/