我如何用 Inkscape 实现图形创作自动化
Inkscape
![](/data/attachment/album/202303/09/113944o6m8mdqmgmq1ey8y.jpg)



> 
> 跟随这个 Inkscape 教程，大量创建会议讲座卡图形。
> 
> 
> 


我录制了一个 [15 分钟长的教程](https://peertube.linuxrocks.online/w/sf8Vqgg3aRkPKpb7KMsHgH)，演示如何在 [Inkscape](http://inkscape.org) 中从 CSV 文件或电子表格中自动生成图形（基本上是邮件合并类图形）。它使用了 Maren Hachmann 的 [Next Generator Inkscape 扩展](https://gitlab.com/Moini/nextgenerator)。


你可以在 [Fedora 设计团队在 Linux Rocks 上的 PeerTube 频道](https://peertube.linuxrocks.online/c/fedora_design/videos)（PeerTube 是开源的！）中观看。


在这篇文章中，我提供了一些关于这个教程相关的背景。我还包括了对视频中内容的一个非常简要的总结，以防你宁愿草草浏览文字而不看视频。


### 会议讲座卡图形


每个 Flock/Nest 都需要为你在举办虚拟会议的在线平台上的每个讲座提供一个图形。像这样的大型活动，通常有大约 50 个或更多的讲座。这需要大量手工制作的图形。


通过本教程，你将学习如何在 Inkscape 中制作这样的模板。


![图片显示 Inkscape 模板的一个例子](/data/attachment/album/202303/09/113958smiv4nhrr4i7xcsi.png)


CSV 文件类似这样：




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


将它们结合起来，CSV 中的每一行生成一个图形，像这样：


![在 Inkscape 模板上显示 CSV 的图片](/data/attachment/album/202303/09/113959g7eztqxqk4mr5mmd.png)


会议图形是你如何应用这个教程的一个好例子。你也可以用它来生成名片（它输出的是 PDF）、个性化的生日邀请函、教室里学生的个性化图形（比如贴在学生课桌上的名卡），以及办公室的铭牌。你也可以用它来创建用于标记物品的图形。[作为 Fedora 设计团队的成员](https://matrix.to/#/#design:fedoraproject.org)，你甚至可以用它来为 Fedora 制作很棒的横幅和图片！你可以用它来制作大量的不同用途。你可以应用这种技术的用途有很多，所以让你的想象力飞翔吧。


### Inkscape Next Generator 扩展


创建这些图片的第一步是安装 Maren Hachmann 为Inkscape 创建的 [Next Generator 扩展](https://gitlab.com/Moini/nextgenerator)。


* 到网站上下载 [next\_gen.inx](https://gitlab.com/Moini/nextgenerator/-/raw/master/next_gen.inx?inline=false) 和 [next\_gen.py](https://gitlab.com/Moini/nextgenerator/-/raw/master/next_gen.py?inline=false)。
* 然后进入 Inkscape的 “<ruby> 编辑 <rt>  Edit </rt></ruby> > <ruby> 首选项 <rt>  Preferences </rt></ruby> > <ruby> 系统 <rt>  System </rt></ruby>”对话框。搜索 “<ruby> 用户扩展 <rt>  User Extensions </rt></ruby>” 目录列表并点击 “<ruby> 打开 <rt>  Open </rt></ruby>” 图标。将 .inx 和 .py 文件拖入该文件夹。
* 最后，你应该关闭所有打开的 Inkscape 窗口并重新启动 Inkscape。新的扩展在 “<ruby> 扩展 <rt>  Extensions </rt></ruby>” 菜单下： “<ruby> 扩展 <rt>  Extensions </rt></ruby> > <ruby> 输出 <rt>  Export </rt></ruby> > Next Generator”。


### 创建一个模板


你的 CSV 文件的每个标题（在我的例子中：`ConferenceName`、`TalkName`、`PresenterNames`）都是一个变量，你可以把它放在 Inkscape 文件中，作为你的模板。[看一下 SVG 模板文件的例子](https://gitlab.com/fedora/design/team/tutorials/inkscape-automation/-/blob/main/template-simple.svg)，以获得指导。如果你想让 `TalkName` 出现在你的模板中，在 Inkscape中创建一个文本对象，并将以下内容放入其中：



```
%VAR_TalkName%

```

当你运行扩展时，`%VAR_TalkName%` 文本将被替换为 CSV 中每一行列出的 `TalkName`。因此，对于第一行，`%VAR_TalkName%` 被替换为第一个图形的文本 `The Pandas Are Marching`。对于第二个图形，`TalkName` 是 `Why Fedora is the Best Linux`。继续，直到给每个图形的加上 `TalkName` 列。


### 运行生成器


一旦你的模板准备好了，通过加载你的 CSV，运行 `Next Generator` 扩展。然后，选择你想在每个文件名中使用的变量（标题名称），点击 “<ruby> 应用 <rt>  Apply </rt></ruby>” 按钮。


在后面的文章中，我将提供一个关于这个扩展的更高级使用的教程，比如改变每个文件中包含的颜色和图形。


本文最初发表在作者的 [博客](https://blog.linuxgrrl.com/2022/07/19/how-to-automate-graphics-production-with-inkscape/)上，经许可后重新发表。




---


via: <https://opensource.com/article/23/3/automate-graphics-production-inkscape>


作者：[Máirín Duffy](https://opensource.com/users/mairin) 选题：[lkxed](https://github.com/lkxed/) 译者：[wxy](https://github.com/wxy) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
I recorded a [15-minute long tutorial](https://peertube.linuxrocks.online/w/sf8Vqgg3aRkPKpb7KMsHgH) demonstrating how to automate the production of graphics from a CSV file or spreadsheet (basically a mailmerge type deal for graphics) in [Inkscape](http://inkscape.org). It uses the [Next Generator Inkscape extension](https://gitlab.com/Moini/nextgenerator) from Maren Hachmann.

You can watch it on the [Fedora Design Team Linux Rocks PeerTube channel](https://peertube.linuxrocks.online/c/fedora_design/videos) (PeerTube is open source!) or the embedded YouTube video below:

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.](https://opensource.com/sites/default/files/2023-02/InkscapeTemplateExample.png)

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

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.](https://opensource.com/sites/default/files/2023-02/Bamboo-Tastes-Better-with-FedoraINKSCAPE.png)

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

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](https://matrix.to/#/#design:fedoraproject.org)! 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](https://gitlab.com/Moini/nextgenerator) for Inkscape created by Maren Hachmann:

- Go to the website and download the
[next_gen.inx](https://gitlab.com/Moini/nextgenerator/-/raw/master/next_gen.inx?inline=false)and[next_gen.py](https://gitlab.com/Moini/nextgenerator/-/raw/master/next_gen.py?inline=false)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](https://gitlab.com/fedora/design/team/tutorials/inkscape-automation/-/blob/main/template-simple.svg) 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 and has been republished with permission.*

## Comments are closed.