diff options
-rw-r--r-- | TODO | 4 | ||||
-rwxr-xr-x | gerbolyze/gerbolyze.py | 26 | ||||
-rwxr-xr-x | setup.py | 22 |
3 files changed, 29 insertions, 23 deletions
@@ -1,2 +1,6 @@ [ ] Do not just return "error 255" if usvg is not installed [ ] Straighten up svg-flatten input unit handling +[ ] split up python code into modules +[ ] Add backwards-compatible vectorize drop-in +[ ] Figure out handling of drill layers +[ ] Re-publish my own pcb-tools, pcb-tools-extension forks with actual maintenance diff --git a/gerbolyze/gerbolyze.py b/gerbolyze/gerbolyze.py index 33a8e31..423adc6 100755 --- a/gerbolyze/gerbolyze.py +++ b/gerbolyze/gerbolyze.py @@ -9,11 +9,8 @@ import base64 import re import sys import warnings -import time import shutil -import math from zipfile import ZipFile, is_zipfile -import shutil from lxml import etree import gerber @@ -21,13 +18,14 @@ from gerber.render.cairo_backend import GerberCairoContext import gerberex import gerberex.rs274x import numpy as np -import cv2 -import enum -import tqdm import click from slugify import slugify -@click.command() +@click.group() +def cli(): + pass + +@cli.command() @click.argument('input_gerbers') @click.argument('output_gerbers') @click.option('-t', '--top', help='Top side SVG overlay') @@ -44,12 +42,11 @@ from slugify import slugify @click.option('--vectorizer', help='passed through to svg-flatten') @click.option('--vectorizer-map', help='passed through to svg-flatten') @click.option('--exclude-groups', help='passed through to svg-flatten') -def paste_vectors(input_gerbers, output_gerbers, top, bottom, +def paste(input_gerbers, output_gerbers, top, bottom, bbox, dilate, no_subtract, subtract, trace_space, vectorizer, vectorizer_map, exclude_groups): - #TODO: describe subtraction script - """ """ + """ Render vector data and raster images from SVG file into gerbers. """ if no_subtract: subtract_map = {} @@ -147,7 +144,7 @@ def paste_vectors(input_gerbers, output_gerbers, top, bottom, print(f'Input file {in_file.name} remained unprocessed. Copying.', file=sys.stderr) shutil.copy(in_file, out_cand) -@click.command() +@cli.command() @click.argument('input') @click.option('-t' ,'--top', help='Top layer output file.') @click.option('-b' ,'--bottom', help='Bottom layer output file. --top or --bottom may be given at once. If neither is given, autogenerate filenames.') @@ -156,8 +153,8 @@ def paste_vectors(input_gerbers, output_gerbers, top, bottom, @click.option('--bbox', help='Output file bounding box. Format: "w,h" to force [w] mm by [h] mm output canvas OR ' '"x,y,w,h" to force [w] mm by [h] mm output canvas with its bottom left corner at the given input gerber ' 'coördinates.') -def render_preview(input, top, bottom, bbox, vector, raster_dpi): - ''' Render gerber file into template to be used with gerbolyze --vectorize. +def template(input, top, bottom, bbox, vector, raster_dpi): + ''' Generate SVG template for gerbolyze paste from gerber files. INPUT may be a gerber file, directory of gerber files or zip file with gerber files ''' @@ -589,5 +586,4 @@ def svg_to_gerber(infile, outfile, layer=None, trace_space:'mm'=0.1, vectorizer= if __name__ == '__main__': - #render_preview() - paste_vectors() + cli() @@ -8,18 +8,24 @@ def readme(): setup( name = 'gerbolyze', - version = '0.1.10', + version = '2.0.0', py_modules = ['gerbolyze'], - scripts = ['gerbolyze'], - description = ('A high-resolution image-to-PCB converter. Gerbolyze reads and vectorizes black-and-white raster ' - 'images, then plots the vectorized image into an existing gerber file while avoiding existing features such as ' - 'text or holes.'), + package_dir = {'': 'gerbolyze'}, + entry_points = ''' + [console_scripts] + gerbolyze=gerbolyze:cli + ''', + description = ('A high-resolution image-to-PCB converter. Gerbolyze plots SVG, PNG and JPG onto existing gerber ' + 'files. It handles almost the full SVG spec and deals with text, path outlines, patterns, arbitrary paths with ' + 'self-intersections and holes, etc. fully automatically. It can vectorize raster images both by contour ' + 'tracing and by grayscale dithering. All processing is done at the vector level without intermediate ' + 'conversions to raster images accurately preserving the input.'), long_description=readme(), long_description_content_type='text/x-rst', - url = 'https://github.com/jaseg/gerbolyze', + url = 'https://git.jaseg.de/gerbolyze', author = 'jaseg', - author_email = 'github@jaseg.net', - install_requires = ['pcb-tools', 'tqdm', 'numpy', 'opencv-python', 'python-slugify', 'lxml'], + author_email = 'github@jaseg.de', + install_requires = ['pcb-tools', 'numpy', 'python-slugify', 'lxml', 'click', 'pcb-tools-extension'], license = 'AGPLv3', classifiers = [ 'Development Status :: 5 - Production/Stable', |