Skip to main content

将任何图像转换为符合六角贴纸标准的图像。

项目描述

从符合贴纸标准的图像自动生成六边形贴纸。

安装

$ pip install hexsticker

在上面列出的安装步骤之后,您将能够使用hexsticker命令:

$ hexsticker --help

要求

  • Python 3.6+

例子

让我们为Selinon 项目创建一个六边形贴纸。

这是输入图像:

<figure class="align-center"> Selinon 输入徽标 </figure>

让我们创建一个六边形贴纸:

$ hexsticker selinon.png -o selinon-sticker-1.png
INFO:hexsticker.create:Writing output to 'selinon-sticker-1.png'

生成的图像是:

<figure class="align-center"> Selinon 六角不干胶贴纸 1 </figure>

如上所示,有一些部分被切断了——让我们为图像添加一些填充:

$ hexsticker input/selinon.png -o output/selinon-sticker-2.png --padding-size 25
INFO:hexsticker.create:Writing output to 'selinon-sticker-2.png'
<figure class="align-center"> Selinon 六角贴纸贴纸 2 </figure>

默认情况下,填充部分是白色的 - 这就是为什么缺少六边形尖峰的原因。让我们将填充区域的颜色设置为与原始图像的背景颜色相同的颜色:

$ hexsticker input/selinon.png -o output/selinon-sticker-3.png --padding-size 25 --padding-color '#66cfa7'
INFO:hexsticker.create:Writing output to 'selinon-sticker-3.png'
<figure class="align-center"> Selinon 六角不干胶贴纸 3 </figure>

好的!我们接下来能做什么?让我们尝试添加一个六边形边框:

$ hexsticker input/selinon.png -o output/selinon-sticker-4.png --padding-size 25 --padding-color '#66cfa7' --border-size 35
INFO:hexsticker.create:Writing output to 'selinon-sticker-4.png'
<figure class="align-center"> Selinon 六角不干胶贴纸 4 </figure>

嗯,在这种情况下,默认的黑色看起来不太好。让我们尝试一些适合配色方案的颜色:

$ hexsticker input/selinon.png -o output/selinon-sticker-5.png --padding-size 25 --padding-color '#66cfa7' --border-size 35 --border-color '#197a9f'
INFO:hexsticker.create:Writing output to 'selinon-sticker-5.png'
<figure class="align-center"> Selinon 六角不干胶贴纸 5 </figure>

请注意,六边形的边缘看起来有点锯齿状。您可以在前面的命令中添加--supersample 2来解决这个问题。给定的数字设置要使用的比例因子。更大的值会导致更平滑的结果,但代价是更高的内存使用率。这种效应的收益递减;通常值 2 就足以获得不错的结果,高于 4 并不会带来太大的改善。

如您所见,此工具可以自动创建六边形贴纸,因此它们遵守六边形标准。随意额外调整您的徽标或输入图像的结果图像。

此工具仅支持光栅图形。

从回购运行

要从存储库运行 hexsticker,请运行以下命令:

$ git clone https://github.com/fridex/hexsticker  # or use ssh
$ cd hexsticker
$ pip3 install -r requirements.txt --user
$ export PYTHONPATH='.'
$ ./hexsticker-cli --help

下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

hexsticker-1.2.0.tar.gz (6.6 kB 查看哈希)

已上传 source

内置分布

hexsticker-1.2.0-py3-none-any.whl (14.2 kB 查看哈希)

已上传 py3