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中定義。其中一些實現直接取自其各自庫的源代碼或基於其各自庫的源代碼。