Merge pull request #28809 from wxy/20230303.1-️-How-I-automate-graphics-creation-with-Inkscape

RP:published/20230303.1 ️ How I automate graphics creation with Inkscape.md
This commit is contained in:
Xingyu.Wang 2023-03-09 11:59:16 +08:00 committed by GitHub
commit 5fd704ef24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 99 additions and 94 deletions

View File

@ -0,0 +1,99 @@
[#]: 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: "wxy"
[#]: reviewer: "wxy"
[#]: publisher: "wxy"
[#]: url: "https://linux.cn/article-15610-1.html"
我如何用 Inkscape 实现图形创作自动化
======
![][0]
> 跟随这个 Inkscape 教程,大量创建会议讲座卡图形。
我录制了一个 [15 分钟长的教程][1],演示如何在 [Inkscape][2] 中从 CSV 文件或电子表格中自动生成图形(基本上是邮件合并类图形)。它使用了 Maren Hachmann 的 [Next Generator Inkscape 扩展][3]。
你可以在 [Fedora 设计团队在 Linux Rocks 上的 PeerTube 频道][4]PeerTube 是开源的!)或下面的嵌入式 YouTube 视频中观看。
![][4a]
在这篇文章中,我提供了一些关于这个教程相关的背景。我还包括了对视频中内容的一个非常简要的总结,以防你宁愿草草浏览文字而不看视频。
### 会议讲座卡图形
每个 Flock/Nest 都需要为你在举办虚拟会议的在线平台上的每个讲座提供一个图形。像这样的大型活动,通常有大约 50 个或更多的讲座。这需要大量手工制作的图形。
通过本教程,你将学习如何在 Inkscape 中制作这样的模板。
![图片显示 Inkscape 模板的一个例子][5]
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 的图片][6]
会议图形是你如何应用这个教程的一个好例子。你也可以用它来生成名片(它输出的是 PDF、个性化的生日邀请函、教室里学生的个性化图形比如贴在学生课桌上的名卡以及办公室的铭牌。你也可以用它来创建用于标记物品的图形。[作为 Fedora 设计团队的成员][7],你甚至可以用它来为 Fedora 制作很棒的横幅和图片!你可以用它来制作大量的不同用途。你可以应用这种技术的用途有很多,所以让你的想象力飞翔吧。
### Inkscape Next Generator 扩展
创建这些图片的第一步是安装 Maren Hachmann 为Inkscape 创建的 [Next Generator 扩展][3]。
- 到网站上下载 [next_gen.inx][8] 和 [next_gen.py][9]。
- 然后进入 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 模板文件的例子][10],以获得指导。如果你想让 `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>” 按钮。
在后面的文章中,我将提供一个关于这个扩展的更高级使用的教程,比如改变每个文件中包含的颜色和图形。
本文最初发表在作者的 [博客][11]上,经许可后重新发表。
--------------------------------------------------------------------------------
via: https://opensource.com/article/23/3/automate-graphics-production-inkscape
作者:[Máirín Duffy][a]
选题:[lkxed][b]
译者:[wxy](https://github.com/wxy)
校对:[wxy](https://github.com/wxy)
本文由 [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/
[0]: https://img.linux.net.cn/data/attachment/album/202303/09/113944o6m8mdqmgmq1ey8y.jpg

View File

@ -1,94 +0,0 @@
[#]: 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/