pyautotrace
v0.0.4
python bintings for AutoTrace。
使用您选择的软件包管理器安装Pyautotrace。
python -m pip install pyautotraceuv add pyautotrace import numpy as np
from autotrace import Bitmap , VectorFormat
from PIL import Image
# Load an image.
image = np . asarray ( Image . open ( "image.jpeg" ). convert ( "RGB" ))
# Create a bitmap.
bitmap = Bitmap ( image )
# Trace the bitmap.
vector = bitmap . trace ()
# Save the vector as an SVG.
vector . save ( "image.svg" )
# Get an SVG as a byte string.
svg = vector . encode ( VectorFormat . SVG )如果您想从源构建包裹,则最简单的方法就是使用紫外线。克隆存储库并在项目目录中运行以下命令。
# Clone the AutoTrace submodule.
git submodule update --init
# If you're on Windows, extract the GLib headers archive.
Expand-Archive " third-partyautotracedistributewin3rdpartyglib-dev_2.34.3-1_win64.zip " -DestinationPath " third-partyglib "
# If you're on macOS, install GLib with Homebrew.
brew install glib
# Build the package with uv.
uv build在Linux和MacOS汇编上,需要在系统上安装GLIB,PKG-CONFIG和UNZIP,默认情况下,大多数Linux发行版都包含。您可以使用brew install glib 。
在Windows上,为了编译生成的C代码,您需要安装Visual C ++构建工具或其他C/C ++编译器。
该项目是根据LGPLV2.1许可证获得许可的。
该项目取决于自动设计项目,该项目是根据LGPLV2.1许可证许可的。 AutoTrace并通过扩展为该项目,要求将GLIB的存在汇编,该项目已在LGPLV2.1许可下许可,但该项目并不依赖GLIB来运行。
该项目包含替代Autotrace和Glib的部分的代码,该代码在overrides.cpp中定义。其中一些实现直接取自其各自库的源代码或基于其各自库的源代码。