Giter Site home page Giter Site logo

jaseg / gerbolyze Goto Github PK

View Code? Open in Web Editor NEW
340.0 20.0 28.0 20.89 MB

Directly render SVG overlays into Gerber and Excellon files

Home Page: https://git.jaseg.de/gerbolyze.git/

License: GNU Affero General Public License v3.0

Python 21.51% CSS 1.05% HTML 6.11% Shell 0.55% Makefile 0.64% C++ 69.74% CMake 0.17% Dockerfile 0.17% Jinja 0.08%
pcb pcb-art pcb-design ecad gerber python python3 opencv vector-graphics vectorization

gerbolyze's Introduction

Gerbolyze high-fidelity SVG/PNG/JPG to PCB converter

Note

The command-line usage and SVG template format of gerbolyze changed between v2.0 and v3.0. You can find details on the new format below under command_line_usage

Gerbolyze renders SVG vector and PNG/JPG raster images into existing gerber PCB manufacturing files. Vector data from SVG files is rendered losslessly without an intermediate rasterization/revectorization step. Still, gerbolyze supports (almost) the full SVG 1.1 spec including complex, self-intersecting paths with holes, patterns, dashes and transformations.

Raster images can either be vectorized through contour tracing (like gerbolyze v1.0 did) or they can be embedded using high-resolution grayscale emulation while (mostly) guaranteeing trace/space design rules.

Try gerbolyze online at https://dyna.kokoroyukuma.de/gerboweb

Drawing by トーコ Toko converted using Gerbolyze and printed at PCBWay.

Drawing by トーコ Toko converted using Gerbolyze and printed at PCBWay.

Tooling for PCB art is quite limited in both open source and closed source ecosystems. Something as simple as putting a pretty picture on a PCB can be an extremely tedious task. Depending on the PCB tool used, various arcane incantations may be necessary and even modestly complex images will slow down most PCB tools to a crawl.

Gerbolyze solves this problem in a toolchain-agnostic way by directly vectorizing SVG vector and PNG or JPG bitmap files onto existing gerber layers. Gerbolyze processes any spec-compliant SVG and "gerbolyzes" SVG vector data into a Gerber spec-compliant form. Gerbolyze has been tested against both the leading open-source KiCAD toolchain and the industry-standard Altium Designer. Gerbolyze is written with performance in mind and will happily vectorize tens of thousands of primitives, generating tens of megabytes of gerber code without crapping itself. With gerbolyze you can finally be confident that your PCB fab's toolchain will fall over before yours does if you overdo it with the high-poly anime silkscreen.

Gerbolyze is based on gerbonara.

image

Tl;dr: Produce high-quality artistic PCBs in three easy steps!

Gerbolyze works in three steps.

  1. Generate a scale-accurate template of the finished PCB from your CAD tool's gerber output:

    $ gerbolyze template --top template_top.svg [--bottom template_bottom.svg] my_gerber_dir
  2. Load the resulting template image Inkscape or another SVG editing program. Put your artwork on the appropriate SVG layer. Dark colors become filled gerber primitives, bright colors become unfilled primitives. You can directly put raster images (PNG/JPG) into this SVG as well, just position and scale them like everything else. SVG clips work for images, too. Masks are not supported.
  3. Vectorize the edited SVG template image drectly into the PCB's gerber files:

    $ gerbolyze paste --top template_top_edited.svg [--bottom ...] my_gerber_dir output_gerber_dir

Quick Start Installation (Any Platform)

python -m pip install --user gerbolyze resvg-wasi

If you already have resvg installed, you can omit the resvg-wasi package.

To uninstall, run

python -m pip uninstall gerbolyze gerbonara resvg-wasi svg-flatten-wasi

To update, run

python -m pip install --user --upgrade --upgrade-strategy eager gerbolyze

Speeding up gerbolyze using natively-built binaries

This will install gerbolyze's binary dependency resvg and gerbolyze's svg-flatten utility as pre-built cross-platform WASM binaries. When you first run gerbolyze, it will take some time (~30s) to link these binaries for your system. The output is cached, so any future run is going to be fast.

WASM is slower than natively-built binaries. To speed up gerbolyze, you can natively build its two binary dependencies:

  1. Install resvg natively using rust's cargo package manager: cargo install resvg
  2. Install gerbolyze's svg-flatten utility natively. You can get pre-built binaries from gerbolyze's gitlab CI jobs at this link by clicking the three dots on the right next to the version you want. These pre-built binaries should work on any x86_64 linux since they are statically linked. You can also build svg-flatten yourself by running make inside the svg-flatten folder from a gerbolyze checkout.

Gerbolyze will pick up these binaries when installed in your $PATH. resvg is also picked up when it is installed by cargo in your home's ~/.cargo, even if it's not in your $PATH. You can override the resvg, usvg or svg-flatten binary that gerbolyze uses by giving it the absoulute path to a binary in the $RESVG, $USVG and $SVG_FLATTEN environment variables.

Build from source (any distro)

git clone --recurse-submodules https://git.jaseg.de/gerbolyze.git
cd gerbolyze

python3 -m venv
source venv/bin/activate
python3 setup.py install

Features

Input on the left, output on the right.

image

  • Almost full SVG 1.1 static spec coverage (!)
    • Paths with beziers, self-intersections and holes
    • Strokes, even with dashes and markers
    • Pattern fills and strokes
    • Transformations and nested groups
    • Proper text rendering with support for complex text layout (e.g. Arabic)
    • <image> elements via either built-in vectorizer or built-in halftone processor
    • (some) CSS
  • Writes Gerber, SVG or KiCAD S-Expression (.kicad_mod) formats
  • Can export from top/bottom SVGs to a whole gerber layer stack at once with filename autodetection
  • Can export SVGs to .kicad_mod files like svg2mod (but with full SVG support)
  • Beziers flattening with configurable tolerance using actual math!
  • Polygon intersection removal
  • Polygon hole removal (!)
  • Optionally vector-compositing of output: convert black/white/transparent image to black/transparent image
  • Renders SVG templates from input gerbers for accurate and easy scaling and positioning of artwork
  • layer masking with offset (e.g. all silk within 1mm of soldermask)
  • Can read gerbers from zip files
  • Limited SVG support for board outline layers (no fill/region support)
  • Dashed lines supported on board outline layers

Gerbolyze is the end-to-end "paste this svg into these gerbers" command that handles all layers on both board sides at once. The heavy-duty computer geometry logic of gerbolyze is handled by the svg-flatten utility (svg-flatten directory). svg-flatten reads an SVG file and renders it into a variety of output formats. svg-flatten can be used like a variant of the popular svg2mod that supports all of SVG and handles arbitrary input <path> elements.

Algorithm Overview

This is the algorithm gerbolyze uses to process a stack of gerbers.

  • Map input files to semantic layers by their filenames
  • For each layer:
    • load input gerber
    • Pass mask layers through gerbv for conversion to SVG
    • Pass mask layers SVG through svg-flatten --dilate
    • Pass input SVG through svg-flatten --only-groups [layer]
    • Overlay input gerber, mask and input svg
    • Write result to output gerber

This is the algorithm svg-flatten uses to process an SVG.

  • pass input SVG through usvg
  • iterate depth-first through resulting SVG.
    • for groups: apply transforms and clip and recurse
    • for images: Vectorize using selected vectorizer
    • for paths:
      • flatten path using Cairo
      • remove self-intersections using Clipper
      • if stroke is set: process dash, then offset using Clipper
      • apply pattern fills
      • clip to clip-path
      • remove holes using Clipper
  • for KiCAD S-Expression export: vector-composite results using CavalierContours: subtract each clear output primitive from all previous dark output primitives

Web interface

You can try gerbolyze online at https://dyna.kokoroyukuma.de/gerboweb

The web interface does not expose all of gerbolyze's bells and whistles, but it allows you to simply paste a single SVG file on a board to try out gerbolyze. Upload your design on the web interface, then download the template for either the top or bottom side, and put your artwork on the appropriate layer of that template using Inkscape. Finally, upload the modified template and let gerbolyze process your design.

Command-line usage

Generate SVG template from Gerber files:

gerbolyze template [options] [--top|--bottom] input_dir_or.zip output.svg

Render design from an SVG made with the template above into a set of gerber files:

gerbolyze paste [options] artwork.svg input_dir_or.zip output_dir_or.zip

Use svg-flatten to convert an SVG file into Gerber or flattened SVG:

svg-flatten [options] --format [gerber|svg] [input_file.svg] [output_file]

Use svg-flatten to convert an SVG file into the given layer of a KiCAD S-Expression (.kicad_mod) file:

svg-flatten [options] --format kicad --sexp-layer F.SilkS --sexp-mod-name My_Module [input_file.svg] [output_file]

Use svg-flatten to convert an SVG file into a .kicad_mod with SVG layers fed into separate KiCAD layers based on their IDs like the popular svg2mod is doing:

Note:

Right now, the input SVG's layers must have ids that match up KiCAD's s-exp layer names. Note that when you name a layer in Inkscape that only sets a name attribute, but does not change the ID. In order to change the ID in Inkscape, you have to use Inkscape's "object properties" context menu function.

Also note that svg-flatten expects the layer names KiCAD uses in their S-Expression format. These are different to the layer names KiCAD exposes in the UI (even though most of them match up!).

For your convenience, there is an SVG template with all the right layer names and IDs located next to this README.

svg-flatten [options] --format kicad --sexp-mod-name My_Module [input_file.svg] [output_file]

gerbolyze template

Usage: gerbolyze template [OPTIONS] INPUT

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. The output file contains a preview image of the input gerbers to allow you to position your artwork, as well as prepared Inkscape layers corresponding to each gerber layer. Simply place your artwork in this SVG template using Inkscape. Starting in v3.0, gerbolyze automatically keeps track of which board side (top or bottom) is contained in an SVG template.

Options:

--top | --bottom

Output top or bottom side template. This affects both the preview image and the prepared Inkscape layers.

--vector | --raster

Embed preview renders into output file as SVG vector graphics instead of rendering them to PNG bitmaps. The resulting preview may slow down your SVG editor.

--raster-dpi FLOAT

DPI for rastering preview

--bbox TEXT

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.

gerbolyze paste

(see below)

Usage: gerbolyze paste [OPTIONS] INPUT_GERBERS OVERLAY_SVG OUTPUT_GERBERS

Render vector data and raster images from SVG file into gerbers. The SVG input file can be generated using gerbolyze template and contains the name and board side of each layer. Note that for board outline layers, handling slightly differs from other layers as PCB fabs do not support filled Gerber regions on these layers.

Options:

--bbox TEXT

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. This must match the ``--bbox`` value given to template!

--subtract TEXT

Use user subtraction script from argument (see below)

--no-subtract

Disable subtraction (see below)

--dilate FLOAT

Default dilation for subtraction operations in mm (see below)

--trace-space FLOAT

Passed through to svg-flatten, see below.

--vectorizer TEXT

Passed through to svg-flatten, see its description below. Also have a look at the examples below.

--vectorizer-map TEXT

Passed through to svg-flatten, see below.

--exclude-groups TEXT

Passed through to svg-flatten, see below.

Outline layers

Outline layers require special handling since PCB fabs do not support filled G36/G37 polygons on these layers. The main difference between normal layers and outline layers is how strokes are handled. On outline layers, strokes are translated to normal Gerber draw commands (D01, D02 etc.) with an aperture set to the stroke's width instead of tracing them to G36/G37 filled regions. This means that on outline layers, SVG end caps and line join types do not work: All lines are redered with round joins and end caps.

One exception from this are patterns, which work as expected for both fills and strokes with full support for joins and end caps.

Dashed strokes are supported on outline layers and can be used to make easy mouse bites.

Subtraction scripts

image

Subtraction scripts tell gerbolyze paste to remove an area around certain input layers to from an overlay layer. When a input layer is given in the subtraction script, gerbolyze will dilate (extend outwards) everything on this input layer and remove it from the target overlay layer. By default, Gerbolyze subtracts the mask layer from the silk layer to make sure there are no silk primitives that overlap bare copper, and subtracts each input layer from its corresponding overlay to make sure the two do not overlap. In the picture above you can see both at work: The overlay contains halftone primitives all over the place. The subtraction script has cut out an area around all pads (mask layer) and all existing silkscreen. You can turn off this behavior by passing --no-subtract or pass your own "script".

The syntax of these scripts is:

{target layer} -= {source layer} {dilation} [; ...]

The target layer must be out.{layer name} and the source layer in.{layer name}. The layer names are gerbolyze's internal layer names, i.e.: paste, silk, mask, copper, outline, drill

The dilation value is optional, but can be a float with a leading + or -. If given, before subtraction the source layer's features will be extended by that many mm. If not given, the dilation defaults to the value given by --dilate if given or 0.1 mm otherwise. To disable dilation, simply pass +0 here.

Multiple commands can be separated by semicolons ; or line breaks.

The default subtraction script is:

out.silk -= in.mask
out.silk -= in.silk+0.5
out.mask -= in.mask+0.5
out.copper -= in.copper+0.5

svg-flatten

Usage: svg-flatten [OPTIONS]... [INPUT_FILE] [OUTPUT_FILE]

Specify - for stdin/stdout.

Options:

-h, --help

Print help and exit

-v, --version

Print version and exit

-o, --format

Output format. Supported: gerber, gerber-outline (for board outline layers), svg, s-exp (KiCAD S-Expression)

-p, --precision

Number of decimal places use for exported coordinates (gerber: 1-9, SVG: >=0). Note that not all gerber viewers are happy with too many digits. 5 or 6 is a reasonable choice.

--clear-color

SVG color to use in SVG output for "clear" areas (default: white)

--dark-color

SVG color to use in SVG output for "dark" areas (default: black)

-f, --flip-gerber-polarity

Flip polarity of all output gerber primitives for --format gerber.

-d, --trace-space

Minimum feature size of elements in vectorized graphics (trace/space) in mm. Default: 0.1mm.

--no-header

Do not export output format header/footer, only export the primitives themselves

--flatten

Flatten output so it only consists of non-overlapping white polygons. This perform composition at the vector level. Potentially slow. This defaults to on when using KiCAD S-Exp export because KiCAD does not know polarity or colors.

--no-flatten

Disable automatic flattening for KiCAD S-Exp export

--dilate

Dilate output gerber primitives by this amount in mm. Used for masking out other layers.

-g, --only-groups

Comma-separated list of group IDs to export.

-b, --vectorizer

Vectorizer to use for bitmap images. One of poisson-disc (default), hex-grid, square-grid, binary-contours, dev-null. Have a look at the examples below.

--vectorizer-map

Map from image element id to vectorizer. Overrides --vectorizer. Format: id1=vectorizer,id2=vectorizer,...

You can use this to set a certain vectorizer for specific images, e.g. if you want to use both halftone vectorization and contour tracing in the same SVG. Note that you can set an <image> element's SVG ID from within Inkscape though the context menu's Object Properties tool.

--force-svg

Force SVG input irrespective of file name

--force-png

Force bitmap graphics input irrespective of file name

-s, --size

Bitmap mode only: Physical size of output image in mm. Format: 12.34x56.78

--sexp-mod-name

Module name for KiCAD S-Exp output. This is a mandatory argument if using S-Exp output.

--sexp-layer

Layer for KiCAD S-Exp output. Defaults to auto-detect layers from SVG layer/top-level group IDs. If given, SVG groups and layers are completely ignored and everything is simply vectorized into this layer, though you cna still use -g for group selection.

-a, --preserve-aspect-ratio

Bitmap mode only: Preserve aspect ratio of image. Allowed values are meet, slice. Can also parse full SVG preserveAspectRatio syntax.

--no-usvg

Do not preprocess input using usvg (do not use unless you know exactly what you're doing)

--usvg-dpi

Passed through to usvg's --dpi, in case the input file has different ideas of DPI than usvg has.

--scale

Scale input svg lengths by this factor (-o gerber only).

-e, --exclude-groups

Comma-separated list of group IDs to exclude from export. Takes precedence over --only-groups.

Gerbolyze image vectorization

Gerbolyze has two built-in strategies to translate pixel images into vector images. One is its built-in halftone processor that tries to approximate grayscale. The other is its built-in binary vectorizer that traces contours in black-and-white images. Below are examples for the four options.

The vectorizers can be used in isolation through svg-flatten with either an SVG input that contains an image or a PNG/JPG input.

The vectorizer can be controlled globally using the --vectorizer flag in both gerbolyze and svg-flatten. It can also be set on a per-image basis in both using --vectorizer-map [image svg id]=[option]["," ...].

--vectorizer poisson-disc (the default)

image

--vectorizer hex-grid

image

--vectorizer square-grid

image

--vectorizer binary-contours

image

The binary contours vectorizer requires a black-and-white binary input image. As you can see, like every bitmap tracer it will produce some artifacts. For artistic input this is usually not too bad as long as the input data is high-resolution. Antialiased edges in the input image are not only OK, they may even help with an accurate vectorization.

GIMP halftone preprocessing guide

Gerbolyze has its own built-in halftone processor, but you can also use the high-quality "newsprint" filter built into GIMP instead if you like. This section will guide you through this. The PNG you get out of this can then be fed into gerbolyze using --vectorizer binary-contours.

1 Import your desired artwork

Though anime or manga pictures are highly recommended, you can use any image including photographs. Be careful to select a picture with comparatively low detail that remains recognizable at very low resolution. While working on a screen this is hard to vizualize, but the grain resulting from the low resolution of a PCB's silkscreen is quite coarse.

image

2 Convert the image to grayscale

image

3 Fine-tune the image's contrast

To look well on the PCB, contrast is critical. If your source image is in color, you may have lost some contrast during grayscale conversion. Now is the time to retouch that using the GIMP's color curve tool.

When using the GIMP's newsprint filter, bright grays close to white and dark grays close to black will cause very small dots that might be beyond your PCB manufacturer's maximum resolution. To control this case, add small steps at the ends of the grayscale value curve as shown (exaggerated) in the picture below. These steps saturate very bright grays to white and very dark grays to black while preserving the values in the middle.

image

4 Retouch details

Therer might be small details that don't look right yet, such as the image's background color or small highlights that merge into the background now. You can manually change the color of any detail now using the GIMP's flood-fill tool.

If you don't want the image's background to show up on the final PCB at all, just make it black.

Particularly on low-resolution source images it may make sense to apply a blur with a radius similar to the following newsprint filter's cell size (10px) to smooth out the dot pattern generated by the newsprint filter.

image

In the following example, I retouched the highlights in the hair of the character in the picture to make them completely white instead of light-gray, so they still stand out nicely in the finished picture.

image

5 Run the newsprint filter

Now, run the GIMP's newsprint filter, under filters, distorts, newsprint.

The first important settings is the spot size, which should be larger than your PCB's minimum detail size (about 10px with gerbolyze render default settings for good-quality silkscreen). In general the cheap and fast standard option of chinese PCB houses will require a larger detail size, but when you order specialty options like large size, 4-layer or non-green color along with a longer turnaround time you'll get much better-quality silk screen.

The second important setting is oversampling, which should be set to four or slightly higher. This improves the result of the edge reconstruction of gerbolyze vectorize.

image

The following are examples on the detail resulting from the newsprint filter.

image

6 Export the image for use with gerbolyze vectorize

Simply export the image as a PNG file. Below are some pictures of the output gerbolyze vectorize produced for this example.

image

image

Manufacturing Considerations

The main consideration when designing artwork for PCB processes is the processes' trace/space design rule. The two things you can do here is one, to be creative with graphical parts of the design and avoid extremely narrow lines, wedges or other thin features that will not come out well. Number two is to keep detail in raster images several times larger than the manufacturing processes native capability. For example, to target a trace/space design rule of 100 µm, the smallest detail in embedded raster graphics should not be much below 1mm.

Gerbolyze's halftone vectorizers have built-in support for trace/space design rules. While they can still produce small artifacts that violate these rules, their output should be close enough to satifsy board houses and close enough for the result to look good. The way gerbolyze does this is to clip the halftone cell's values to zero whenevery they get too small, and to forcefully split or merge two neighboring cells when they get too close. While this process introduces slight steps at the top and bottom of grayscale response, for most inputs these are not noticeable.

On the other hand, for SVG vector elements as well as for traced raster images, Gerbolyze cannot help with these design rules. There is no heuristic that would allow Gerbolyze to non-destructively "fix" a design here, so all that's on the roadmap here is to eventually include a gerber-level design rule checker.

As far as board houses go, I have made good experiences with the popular Chinese board houses. In my experience, JLC will just produce whatever you send them with little fucks being given about design rule adherence or validity of the input gerbers. This is great if you just want artistic circuit boards without much of a hassle, and you don't care if they come out exactly as you imagined. The worst I've had happen was when an older version of gerbolyze generated polygons with holes assuming standard fill-rule processing. The in the board house's online gerber viewer things looked fine, and neither did they complain during file review. However, the resulting boards looked completely wrong because all the dark halftones were missing.

PCBWay on the other hand has a much more rigurous file review process. They <em>will</em> complain when you throw illegal garbage gerbers at them, and they will helpfully guide you through your design rule violations. In this way you get much more of a professional service from them and for designs that have to be functional their higher level of scrutiny definitely is a good thing. For the design you saw in the first picture in this article, I ended up begging them to just plot my files if it doesn't physically break their machines and to their credit, while they seemed unhappy about it they did it and the result looks absolutely stunning.

PCBWay is a bit more expensive on their lowest-end offering than JLC, but I found that for anything else (large boards, multi-layer, gold plating etc.) their prices match. PCBWay offers a much broader range of manufacturing options such as flexible circuit boards, multi-layer boards, thick or thin substrates and high-temperature substrates.

When in doubt about how your design is going to come out on the board, do not hesitate to contact your board house. Most of the end customer-facing online PCB services have a number of different factories that do a number of different fabrication processes for them depending on order parameters. Places like PCBWay have exceptional quality control and good customer service, but that is mostly focused on the technical aspects of the PCB. If you rely on visual aspects like silkscreen uniformity or solder mask color that is a strong no concern to everyone else in the electronics industry, you may find significant variations between manufacturers or even between orders with the same manufacturer and you may encounter challenges communicating your requirements.

Limitations

SVG raster features

Currently, SVG masks and filters are not supported. Though SVG is marketed as a "vector graphics format", these two features are really raster primitives that all SVG viewers perform at the pixel level after rasterization. Since supporting these would likely not end up looking like what you want, it is not a planned feature. If you need masks or filters, simply export the relevant parts of the SVG as a PNG then include that in your template.

Gerber pass-through

Since gerbolyze has to composite your input gerbers with its own output, it has to fully parse and re-serialize them. gerbolyze gerbonara for all its gerber parsing needs. Thus, gerbonara will interpret your gerbers and output will be in gerbonara's gerber "dialect". If you find a corner case where this does not work and the output looks wrong, please file a bug report with an example file on the gerbonara bug tracker. Always check the output files for errors before submitting them to production.

Gerbolyze is provided without any warranty, but still please open an issue or send me an email if you find any errors or inconsistencies.

Trace/Space design rule adherence

While the grayscale halftone vectorizers do a reasonable job adhering to a given trace/space design rule, they can still produce small parts of output that violate it. For the contour vectorizer as well as for all SVG primitives, you are responsible for adhering to design rules yourself as there is no algorithm that gerboyze could use to "fix" its input.

A design rule checker is planned as a future addition to gerbolyze, but is not yet part of it. If in doubt, talk to your fab and consider doing a test run of your design before ordering assembled boards ;)

image

For a demonstration of gerbolyze convert, check out the Gerbolyze Protoboard Index, where you can download gerber files for over 7.000 SMD and THT protoboard layouts.

Licensing

This tool is licensed under the rather radical AGPLv3 license. Briefly, this means that you have to provide users of a webapp using this tool in the backend with this tool's source.

I get that some people have issues with the AGPL. In case this license prevents you from using this software, please send me an email and I can grant you an exception. I want this software to be useful to as many people as possible and I wouldn't want the license to be a hurdle to anyone. OTOH I see a danger of some cheap board house just integrating a fork into their webpage without providing their changes back upstream, and I want to avoid that so the default license is still AGPL.

gerbolyze's People

Contributors

jaseg avatar xengi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gerbolyze's Issues

Documentation for svg-flatten CLI incorrect

I've just installed the package through pip on OSX Ventura 13.4.1. I was struggling with using the svg-flatten module since the documentation says to call it with

svg-flatten [options]

This, however, results in an error that the module cannot be found.

Then I looked into the setup.py for the svg-flatten module and found that the script should be called using

wasi-svg-flatten [options]

Now it works with no problem.

Should either the documentation or the setup.py file be updated?

Gerbolyze convert fails silently when an SVG contains a polygon with a large number of points.

Description

Gerbolyze fails to produce all layers contained in a template SVG generated by the empty-template sub-command when one of the layers contains a polygon with many points. The following can be used to generate a test SVG as well as demonstrate that the directory is lacking the expected set of files:

import numpy as np
import subprocess

from bs4 import BeautifulSoup
from pathlib import Path

def generate_polygon_and_append(soup, layer, radius, point_count=5e5, **kwargs):
    theta_array = np.linspace(0, 2*np.pi, num=int(point_count))
    # don't remember how numpy concat works rn so do it ugly
    point_array = np.array([radius * np.cos(theta_array), radius * np.sin(theta_array)]).transpose() + radius
    points = ' '.join([f'{x}, {y}' for (x, y) in point_array])
    layer.append(soup.new_tag('polygon', points=points, **kwargs))

def recursive_rmdir(directory):
    directory = Path(directory)
    for item in directory.iterdir():
        if item.is_dir():
            rmdir(item)
        else:
            item.unlink()
    directory.rmdir()

def main(output_dir='./gerbolyze_polygon_size_test', svg_template_name='gerbolyze_polygon_size_test.svg', point_count=512):
    output_dir_path = Path(output_dir).resolve()
    print(output_dir_path.as_posix())
    output_dir_path.mkdir(parents=True, exist_ok=True)
    svg_template_name_path = output_dir_path.joinpath(svg_template_name)
    if svg_template_name_path.exists():
        svg_template_name_path.unlink()

    maximum_radius = 50

    # Call Gerbolyze to generate an empty template SVG.
    command = ['gerbolyze', 'empty-template', f'--size {2*(maximum_radius)}x{2*(maximum_radius)}mm', svg_template_name_path.as_posix()]
    subprocess.run(' '.join(command), shell=True)

    # Open file we just generated.
    with svg_template_name_path.open() as svg_template:
        svg_template_soup = BeautifulSoup(svg_template, 'xml')

    # Construct SVG.
    for layer in svg_template_soup.find_all('g'):
        if layer['id'] == 'g-top-copper':
            generate_polygon_and_append(svg_template_soup, layer, maximum_radius)
        if layer['id'] == 'g-bottom-copper':
            generate_polygon_and_append(svg_template_soup, layer, maximum_radius)

    with svg_template_name_path.open('w') as svg_template:
        svg_template.write(svg_template_soup.prettify())

    # Call Gerbolyze program to convert SVG to Gerber.
    gerber_dir_path = output_dir_path.joinpath('gerber')
    if gerber_dir_path.exists():
        recursive_rmdir(gerber_dir_path)
    command = ['gerbolyze', 'convert', svg_template_name_path.as_posix(), gerber_dir_path.as_posix()]
    subprocess.run(' '.join(command), shell=True)

if __name__=='__main__':
    main()

This python script will create a directory called gerbolyze_polygon_size_test, populate it with a template SVG generated by Gerbolyze with two large polygons (with 5e5 points) added to the top and bottom copper layers, then call Gerbolyze to convert this SVG to Gerber files in a new subdirectory called gerber. The result of this on my machine appears as follows:

$ ls -hall ./gerbolyze_polygon_size_test/gerber_validation 
total 13M
drwxr-xr-x 2 luke users   6 Mar 19 21:52 .
drwxr-xr-x 4 luke users   5 Mar 19 21:52 ..
-rw-r--r-- 1 luke users 13M Mar 19 21:52 gerbolyze_polygon_size_test-F.Cu.gbr
-rw-r--r-- 1 luke users  86 Mar 19 21:52 gerbolyze_polygon_size_test-F.Mask.gbr
-rw-r--r-- 1 luke users  86 Mar 19 21:52 gerbolyze_polygon_size_test-F.Paste.gbr
-rw-r--r-- 1 luke users  86 Mar 19 21:52 gerbolyze_polygon_size_test-F.SilkS.gbr

Notably, this is missing the bottom copper layer, which we know in this case has elements in the SVG.

Expected Behavior

First, Gerbolyze should not fail silently in these cases - there should be some sort of warning or failure reported, which is not the case when I run this (from my shell, the python script is not hiding any stdout). Second, this probably shouldn't fail at all - the layers that are written appear to be correct when zipped and viewed with the Gerber viewer tool in KiCad. This level of resolution is useful for me, as I am using geometry from the boundary edges of a face of a high-resolution, manifold mesh to construct polygons in the template SVGs.

Can't build on Ubuntu

I hate to be that guy who is clueless about what exactly is going wrong, but I really want to try out this software and can't get this to build in a fresh Ubuntu virtual machine.

Before I bother you too much with what's going wrong, can you tell me the exact version of python that I should be using to install, as it is ambiguous and depending on which version I try to use, I get different errors.

There's also some errors due to upgrading pip3 to a point where even running pip3 with no args will fail with syntax errors, I think because it's using a python older than 3.x

Just want a known good starting point to try first and then I can show you error logs while trying to get it installed.

USVG_OPTIONS='--keep-named-groups' required

I'm trying to use this tool, but I have to yet succeed once. So far I managed to find one problem: usvg seems to be removing all groups from the svg file, unless we tell it not to with the --keep-named-groups option. Simply adding USVG_OPTIONS='--keep-named-groups' before the gerbolyze command does that, and gets rid of the Corresponding overlay layer not found. Skipping. errors.

I'm still getting empty output, though, so there must be more bugs to find.

FileNotFoundError: [Errno 2] No such file or directory: 'gerbv'

hello !

i'm trying to convert my edited svg template back to gerbera, but got an error:
FileNotFoundError: [Errno 2] No such file or directory: 'gerbv'

full log:

$ gerbolyze paste --top /Users/chrpsh/Downloads/EMIMic_v2/EMIMic_v2.preview-top.svg /Users/chrpsh/Downloads/EMIMic_v2 /Users/chrpsh/Downloads/EMIMic_v2/exp_tst

#########################################
processing  top input file  /Users/chrpsh/Downloads/EMIMic_v2/EMIMic_v2.preview-top.svg
#########################################

loading silk layer from: /Users/chrpsh/Downloads/EMIMic_v2/EMIMic_v2.GTO
loading mask layer from: /Users/chrpsh/Downloads/EMIMic_v2/EMIMic_v2.GTS
loading copper layer from: /Users/chrpsh/Downloads/EMIMic_v2/EMIMic_v2.GTL
loading outline layer from: /Users/chrpsh/Downloads/EMIMic_v2/EMIMic_v2.GM1
loading drill layer from: /Users/chrpsh/Downloads/EMIMic_v2/EMIMic_v2.TXT
loaded layers: ['silk', 'mask', 'copper', 'outline', 'drill']
bounds: ((0.0, 2.1063), (0.0, 3.7795))

-----------------------------------------
processing side top layer silk
-----------------------------------------

rendering layer silk
svg-flatten args: --format gerber --precision 6 --trace-space 0.1 --only-groups g-silk /Users/chrpsh/Downloads/EMIMic_v2/EMIMic_v2.preview-top.svg /var/folders/bp/j7_pnwr93zb0352wfgrjmvk00000gn/T/tmpb7iolkkb/overlay-top-silk.gbr
copying svg input into temp svg
calling usvg on "/var/tmp/tmp.0.SauvhX.svg" and "/var/tmp/tmp.1.Xr55dy.svg"
parsed 0 vectorizers
Loading temporary file "/var/tmp/tmp.1.Xr55dy.svg"
loaded viewbox: 0, 0, 2.1063, 3.7795
document viewbox clip: bbox={0, 0} - {21063000, 37795000}
Forwarding layer name to sink: "g-silk"
used svg-flatten: svg-flatten
compositing
processing dilation mask 0.1
dilating mask by 0.1
dilation cmd: gerbv -x svg --border=0 --origin=0.000000x0.000000 --window_inch=0.082925x0.148799 --foreground=#ffffff -o /var/folders/bp/j7_pnwr93zb0352wfgrjmvk00000gn/T/tmpb7iolkkb/dilate-tmp.svg /Users/chrpsh/Downloads/EMIMic_v2/EMIMic_v2.GTS
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/gerbolyze", line 33, in <module>
    sys.exit(load_entry_point('gerbolyze==2.1.1', 'console_scripts', 'gerbolyze')())
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gerbolyze.py", line 181, in paste
    dilated = do_dilate(d_layer, amount)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gerbolyze.py", line 139, in do_dilate
    dilate_gerber(layers, layer, amount, bbox, tmpdir, outfile, units, curve_tolerance)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gerbolyze.py", line 599, in dilate_gerber
    subprocess.run(cmd, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 1842, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'gerbv'

how can i fix this? (tried to use sudo, same output)
thank you

SystemError: resvg executable not found

Based on the documentation it seems that one doesn't need to install 'resvg' unless one wants to speed up execution.

However, running 'gerbolyze template', I get the following error:

  File "/mydata/gerbolyze/venv/bin/gerbolyze", line 5, in <module>
    gerbolyze.cli()
  File "/mydata/gerbolyze/venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/mydata/gerbolyze/venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/mydata/gerbolyze/venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/mydata/gerbolyze/venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/mydata/gerbolyze/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/mydata/gerbolyze/venv/lib/python3.10/site-packages/gerbolyze/__init__.py", line 181, in template
    run_cargo_command('resvg', temp_svg.name, temp_png.name, dpi=f'{raster_dpi:.0f}')
  File "/mydata/gerbolyze/venv/lib/python3.10/site-packages/gerbolyze/__init__.py", line 432, in run_cargo_command
    raise SystemError(f'{binary} executable not found')
SystemError: resvg executable not found```

Note: I also don't have 'rust' or 'cargo' installed -- are they prerequisites?  I don't see them mentioned in the docs except in the seemingly optional section of speeding up with native binaries.

svg-flatten stuck on gerbolyze::dehole_polytree()

Hi,

When trying to generate gerbers from SVGs for internal PCB layers, I had a case of svg-flatten being stuck forever.
I edited the shape in Inkscape, and I trimmed in order to get the simplest shape that causes the issue.

Looking at the code, it seems gerbolyze::dehole_polytree() is stuck in an infinite loop.
I tried debugging further but I need to familiarize myself more with that code at the moment.

Version used: Local build of 3.1.5

Command:
svg-flatten --format gerber -f flatten_stuck.svg /tmp/test.gbr

flatten_stuck.svg

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<svg
   version="1.1"
   id="Calque_1"
   x="0px"
   y="0px"
   width="88.567993"
   height="44.890415"
   viewBox="0 0 88.567993 44.890416"
   enable-background="new 0 0 829.5 1018.667"
   xml:space="preserve"
   sodipodi:docname="flatten_stuck.svg"
   inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg">
<g
   opacity="0.5"
   id="g8183"
   transform="translate(-171.84351,-49.776241)"><path
   id="path8181"
   d="m 260.4115,92.716241 v -42.94 l -87.98708,1.369466 c -7.16052,53.374633 53.58638,43.46921 87.98708,41.570534 z M 186.499,86.183 c -1.09,0 -1.98,-0.89 -1.98,-1.98 0,-1.1 0.89,-1.99 1.98,-1.99 1.1,0 1.99,0.89 1.99,1.99 0,1.09 -0.89,1.98 -1.99,1.98 z m 65,0 c -1.09,0 -1.98,-0.89 -1.98,-1.98 0,-1.1 0.89,-1.99 1.98,-1.99 1.1,0 1.99,0.89 1.99,1.99 0,1.09 -0.89,1.98 -1.99,1.98 z"/>
</g>
</svg>

Edit: removed the attachment and copied the SVG contents

No Change using --scale or --usvg-dpi

Hi;
This is an incredible toolbox, well done on making it!

I've been experiencing an issue related to illustrator exporting SVG that are scaled wrong. This has to do with the viewbox field in the SVG. There are numerous issues in online forums about this within illustrator.

I thought I might be able to account for this (scaling by 0.66) in command line with Gerbolyze.
I've invoked svg-flatten --format svg --scale 0.66 /home/path/to/svg.svg /home/path/to/out.svg
I've also tried
svg-flatten --format kicad --sexp-mod-name TestModule --scale 0.66 /home/path/to/svg,svg /home/path/to/out.kicad_mod

I've also tried to address this with the --usvg-dpi flag, but also have seen no effect.
I've tried svg-flatten --format kicad --sexp-mod-name TestModule --usvg-dpi 72 home/path/to/svg.svg /home/path/to/out.kicad_mod

I get no acknowledgement of either of these switches being thrown, but I also get no errors. Am I missing something on when these can be toggled?

I've attached a troublesome SVG (hilarious that Github doesn't support SVG uploads) to this post if anyone wants to experiment. It should be 53.3 x 32.3 mm. It seems to always come into KiCad as 151 x 92 mm
2_nostroke_clipping_mask_noresp.zip

very cool!

thanks! this is what i always want to do with svg2sz but have no time and clue, im looking a way to integrate to svg2sz...

Bezier flattener flattens beziers too much

I'm trying to get some icons onto my silkscreen, but no matter what I try it comes out super "low resolution", for lack of a better term. Specifically circles seem to become rotated squares.

For example, I tried various music note icons from various websites:

https://www.svgrepo.com/vectors/music/monocolor/
https://feathericons.com/?query=note
https://remixicon.com/

(any of those should do)

I put them on the silk layer in inkscape. I've tried embedding png images but that didn't get included in the silk layer at all. Had to draw some primitives onto the silk layer to make sure the process is working end to end. All I've gotten to show up on the gerber is if I drag in a svg file and choose to include it (first radio button. ie. not as an image tag).

inkscape

gerber

This is just a test to get some screenshots. When I make the icons smaller (which would be my intention for how I'd want to use it in this case) the effect is even more pronounced.

Is there something obvious I'm missing? A setting I have to change perhaps? Would be nice if the round parts looked a bit rounder.

Error trying to use svg-flatten

Hi,

I'm trying to test the svg-flatten code using the provided test images:

./svg-flatten --format gerber last_dash.svg dash.grb

but I get this error: Error: Cannot find usvg. Is it installed and in $PATH?

Can you please tell me what am I missing?

Thank you.

Best,
Radu

better instructions how to use this would be appreciated.

I have a really hard time to get this running, help is appreciated.
If I run "gerbolyze convert test.svg test.gbr" on my machine (WSL linux on Windows 11) I get the following error which I am not sure what the problem is. I assume that the test.svg in the repository good, but I am not even sure about that?

used usvg: wasi-usvg
Info: Skipping usvg
used svg_flatten_wasi python package
Traceback (most recent call last):
File "/home/stefan/.local/bin/gerbolyze", line 5, in
gerbolyze.cli()
File "/home/stefan/anaconda3/lib/python3.9/site-packages/click/core.py", line 1128, in call
return self.main(*args, **kwargs)
File "/home/stefan/anaconda3/lib/python3.9/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/home/stefan/anaconda3/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/stefan/anaconda3/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/stefan/anaconda3/lib/python3.9/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/home/stefan/.local/lib/python3.9/site-packages/gerbolyze/init.py", line 265, in convert
bounds = stack.board_bounds()
File "/home/stefan/anaconda3/lib/python3.9/site-packages/gerbonara/layers.py", line 516, in board_bounds
if self.outline:
File "/home/stefan/anaconda3/lib/python3.9/site-packages/gerbonara/layers.py", line 637, in outline
return self['mechanical outline']
File "/home/stefan/anaconda3/lib/python3.9/site-packages/gerbonara/layers.py", line 605, in getitem
return self.graphic_layers[(side, use)]
KeyError: ('mechanical', 'outline')

Minor issue: Git clone doesn't point to a branch

Running the suggested command:
git clone --recurse-submodules https://git.jaseg.de/gerbolyze.git
gives the following error:
warning: remote HEAD refers to nonexistent ref, unable to checkout.

Workaround is to run:
git branch -a
and then checkout one of the branches, e.g.,
git checkout main

Suggest either this is "fixed" or noted in the documentation.

opencv error

$ ls -l
total 4.6M
-rw-rw-r-- 1 xengi xengi  32K 2018-06-28 22:14:12 002.png
-rw-rw-r-- 1 xengi xengi 2.9M 2015-12-11 01:34:57 CX_4800304000.stp
drwxrwxr-x 2 xengi xengi 4.0K 2019-03-24 17:58:12 HIROSE_CX70M-24P1.pretty/
-rw-rw-r-- 1 xengi xengi 1.6K 2019-03-26 00:16:00 README.md
-rw-rw-r-- 1 xengi xengi  27K 2019-03-26 00:16:52 darling-B.Cu.gbr
-rw-rw-r-- 1 xengi xengi  23K 2019-03-26 00:16:52 darling-B.Mask.gbr
-rw-rw-r-- 1 xengi xengi  494 2019-03-26 00:16:52 darling-B.Paste.gbr
-rw-rw-r-- 1 xengi xengi 8.0K 2019-03-26 00:16:52 darling-B.SilkS.gbr
-rw-rw-r-- 1 xengi xengi 1.1K 2019-03-26 00:16:52 darling-Edge.Cuts.gbr
-rw-rw-r-- 1 xengi xengi  89K 2019-03-26 00:16:52 darling-F.Cu.gbr
-rw-rw-r-- 1 xengi xengi  54K 2019-03-26 00:16:52 darling-F.Mask.gbr
-rw-rw-r-- 1 xengi xengi  50K 2019-03-26 00:16:52 darling-F.Paste.gbr
-rw-rw-r-- 1 xengi xengi  14K 2019-03-26 00:16:52 darling-F.SilkS.gbr
-rw-rw-r-- 1 xengi xengi  275 2019-03-26 00:23:26 darling-NPTH.drl
-rw-rw-r-- 1 xengi xengi  862 2019-03-26 00:23:26 darling-PTH.drl
-rw-rw-r-- 1 xengi xengi 5.7K 2019-03-26 00:02:27 darling-cache.lib
-rw-rw-r-- 1 xengi xengi  11K 2019-03-24 17:58:38 darling.bak
-rw-rw-r-- 1 xengi xengi  79K 2019-03-26 00:22:43 darling.kicad_pcb
-rw-rw-r-- 1 xengi xengi  73K 2019-03-26 00:18:07 darling.kicad_pcb-bak
-rw-rw-r-- 1 xengi xengi  13K 2019-03-26 00:22:27 darling.net
-rw-r--r-- 1 xengi xengi 1.1K 2019-03-26 00:22:41 darling.pro
-rw-rw-r-- 1 xengi xengi  11K 2019-03-26 00:02:26 darling.sch
-rw-rw-r-- 1 xengi xengi 289K 2019-03-26 00:03:37 darling_3d.png
-rw-rw-r-- 1 xengi xengi  89K 2019-03-26 00:01:53 darling_pcb.png
-rw-rw-r-- 1 xengi xengi  39K 2019-03-26 00:02:49 darling_schema.png
-rw-rw-r-- 1 xengi xengi    2 2019-03-26 00:44:55 fp-info-cache
-rw-rw-r-- 1 xengi xengi  125 2019-03-24 17:57:53 fp-lib-table
-rw-rw-r-- 1 xengi xengi 114K 2019-03-26 00:24:15 preview.png
-rw-rw-r-- 1 xengi xengi 480K 2019-03-26 00:41:05 preview.xcf
-rw-rw-r-- 1 xengi xengi 142K 2019-03-26 00:41:38 preview_002.png
$ gerbolyze vectorize bottom . out/ preview_002.png
Target layer file darling-B.SilkS.gbr
Outline layer file darling-Edge.Cuts.gbr
Parsing outline gerber
  * outline has offset (117.0, -130.5), size (24.0, 14.0)
Parsing target gerber
  * target layer has offset (124.238095, -129.816666), size (13.200000000000003, 12.307142999999996)
  * source image has size (1575, 919), going for scale 66dpmm
Combining keepout composite
  * outline
  * target layer
  * extra layer darling-B.Mask.gbr
Rendering keepout composite
Expanding keepout composite by 21
Thresholding source image
Padding source image
off (4, 2) end (1579, 921) img (1575, 919) tgt (1584, 924)
Masking source image
Calculating contour lines
    Extracting contours
Traceback (most recent call last):
  File "/home/xengi/.local/bin/gerbolyze", line 32, in <module>
    gerbolyze.process_gerbers(args.source, args.target, args.image, args.side, args.layer, args.debugdir)
  File "/home/xengi/.local/venvs/gerbolyze/lib/python3.7/site-packages/gerbolyze.py", line 342, in process_gerbers
    out = paste_image(tgrb, ogrb, source_img, [subtract], debugdir=debugdir, status_print=lambda *args: print(*args, flush=True))
  File "/home/xengi/.local/venvs/gerbolyze/lib/python3.7/site-packages/gerbolyze.py", line 208, in paste_image
    status_print=lambda *args: status_print('   ', *args))
  File "/home/xengi/.local/venvs/gerbolyze/lib/python3.7/site-packages/gerbolyze.py", line 231, in plot_contours
    img_cont_out, contours, hierarchy = cv2.findContours(img, cv2.RETR_TREE, cv2.CHAIN_APPROX_TC89_KCOS)
ValueError: not enough values to unpack (expected 3, got 2)
$ pip freeze
cairocffi==0.9.0
cffi==1.12.2
gerbolyze==0.1.8
numpy==1.16.2
opencv-python==4.0.0.21
pcb-tools==0.1.6
pycparser==2.19
tqdm==4.31.1
$ python --version
Python 3.7.2

Examples

Can we get at least one step by step example how to use this tool?
There're some command lines in description but they show options that are not documented anywhere and in general I have no idea how to make my SVG files into gerbers. how to prepare them, etc.

Problem with easyEDA files.

I tried multiple gerber files from easyEDA pro on multiple machines.

I get this error.
python -m gerbolyze template --top 294f763686bd4bc0b0d0cfd0dafab3b4_1704711853000.zip output.
svg
Traceback (most recent call last):
File "C:\Users\Modalen\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Modalen\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\Modalen\AppData\Roaming\Python\Python39\site-packages\gerbolyze_main
.py", line 2, in
gerbolyze.cli()
File "C:\Users\Modalen\AppData\Roaming\Python\Python39\site-packages\click\core.py", line 1157, in call
return self.main(*args, **kwargs)
File "C:\Users\Modalen\AppData\Roaming\Python\Python39\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
File "C:\Users\Modalen\AppData\Roaming\Python\Python39\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\Modalen\AppData\Roaming\Python\Python39\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\Modalen\AppData\Roaming\Python\Python39\site-packages\click\core.py", line 783, in invoke
return _callback(*args, **kwargs)
File "C:\Users\Modalen\AppData\Roaming\Python\Python39\site-packages\gerbolyze_init
.py", line 130, in template
svg = stack.to_pretty_svg(side=('top' if top else 'bottom'), inkscape=True)
File "C:\Users\Modalen\AppData\Roaming\Python\Python39\site-packages\gerbonara\layers.py", line 720, in to_pretty_svg
objects.insert(0, tag('path', id='outline-path', d=self.outline_svg_d(unit=svg_unit), style='fill:white'))
File "C:\Users\Modalen\AppData\Roaming\Python\Python39\site-packages\gerbonara\layers.py", line 942, in outline_svg_d
for chain in chains:
File "C:\Users\Modalen\AppData\Roaming\Python\Python39\site-packages\gerbonara\layers.py", line 972, in outline_polygons
x_left = bisect.bisect_left (by_x, x, key=lambda elem: elem[0] + tol)
TypeError: 'key' is an invalid keyword argument for bisect_left()

PermissionError: [Errno 13] on Gerbolyze Paste

When using Gerbolyze paste, the program throws an error after the Overlay Mechanical Outline layer.

In this instance, KicadGerberOUT is the original set of gerber files, input.svg is an inkspace SVG made with the template from gerbolyze template, and KicadGerberIN is an empty output directory.

gerbolyze paste KicadGerberOUT input.svg KicadGerberIN

Output error and traceback:

Traceback (most recent call last):
  File "/usr/local/bin/gerbolyze", line 4, in <module>
    __import__('pkg_resources').run_script('gerbolyze==3.0.11', 'gerbolyze')
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 667, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1463, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python3.8/dist-packages/gerbolyze-3.0.11-py3.8.egg/EGG-INFO/scripts/gerbolyze", line 5, in <module>
    gerbolyze.cli()
  File "/home/rorofat/.local/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/rorofat/.local/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/rorofat/.local/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/rorofat/.local/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/rorofat/.local/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/gerbolyze-3.0.11-py3.8.egg/gerbolyze/__init__.py", line 92, in paste
    stack.save_to_directory(output_gerbers)
  File "/usr/local/lib/python3.8/dist-packages/gerbonara-0.11.1-py3.8.egg/gerbonara/layers.py", line 426, in save_to_directory
    layer.save(out)
  File "/usr/local/lib/python3.8/dist-packages/gerbonara-0.11.1-py3.8.egg/gerbonara/cam.py", line 419, in save
    shutil.copy(self.original_path, filename)
  File "/usr/lib/python3.8/shutil.py", line 418, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.8/shutil.py", line 264, in copyfile
    with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: 'KicadGerberIN/PCB Json-F_Cu.gbr'

MacOS support?

Howdy, thank you for all of the work you've put into this! I would love to be able to use this on MacOS.

Since this could significantly make my life easier I'm happy to pay to see this feature - either via github sponsorship, ko-fi, paypal, or a donation to a non-profit of your choice.

Thanks again for this! 💜

gerbolyze only fills coutouts

Hey, I ran into a problem. My board has a few cutouts and gerbolyze vectorize rendered my image only onto/into the cutouts, is there a quick fix for this problem?

Thank you in advance, gerbolyze is an amazing tool! :)

Error when trying to create template

  File "/root/.local/lib/python3.10/site-packages/gerbonara/graphic_primitives.py", line 217, in flip
    cx=(self.x + self.cx) - self.x2, cy=(self.y + self.cy) - self.y2, clockwise=not self.clockwise)
AttributeError: 'Arc' object has no attribute 'x'. Did you mean: 'cx'?
root@home-pc:~#

After poking around in graphic_primitives.py I did manage to get and SVG output but it didn't seem to be right.

Using paste command / Problem with gerbv

Hi,

when I try to use gerbolyze paste I get an error. It seems like there is a problem with gerbv. But I'm not sure, if I did something wrong or if something else is broken.
I'm on macOs 11.3.1

subprocess.CalledProcessError: Command '['gerbv', '-x', 'svg', '--border=0', '--origin=4.972441x-5.032677', '--window_inch=3.103150x1.131890', '--foreground=#ffffff', '-o', '/var/folders/dd/fmghlwq1677bxlf1n9f_qjwm0000gn/T/tmpu2mco5z3/dilate-tmp.svg', 'oscger/OSC-F_Mask.gbr']' returned non-zero exit status 1.

How do you increase resolution of included images

I used Inkscape to add a high resolution JPEG photo to the bottom silkscreen layer.
I tried both with the original 9MB color image and separately with a 17MB B&W dithered version of the same image.
The resulting SVG templates output by Inkscape ended up being 14MB and 23MB respectively -- so the resolution was captured by Inkscape.

In both cases, the resulting Gerber file showed only a very low resolution image (though still a little higher than the native image import tool in EasyEDA). Note that the Gerber zip file increased by only about 1.5MB.

(Interestingly, when I used Inkscape to crop the same image and then resized the smaller cropped image to the same size as the original, the resolution of the Gerber image was even worse with larger 'circles')

I am using the default settings (and thus presumably the default vectorizer) in 'gerbolyze paste'.

Is there any way to increase the resolution?
(e.g., setting the minimum size of the poisson discs/squares/hex etc)
It would seem that the silkscreen layer should handle finer resolutions -- after all it prints tiny letters and thin lines.

Gerbolyze (through svg-flatten-wasi and gerbonara) is incompatible with python < 3.10

I am trying to install gerbolyze in python3 venv (running under Ubuntu 18.04)

I get the following error:

$  python3 -m pip install --user gerbolyze
Collecting gerbolyze
  Using cached https://files.pythonhosted.org/packages/3f/2e/231077f2f8731e0725427aace057778e6aff5e2b11f3c7a805f81c1e2e22/gerbolyze-3.1.5-py3-none-any.whl
Collecting svg-flatten-wasi (from gerbolyze)
  Could not find a version that satisfies the requirement svg-flatten-wasi (from gerbolyze) (from versions: )
No matching distribution found for svg-flatten-wasi (from gerbolyze)```

Add smarter background handling

Currently, when converting an SVG file with black background and white foreground using --format gerber will produce clear gerber primitives on top of clear background in the output. We should figure out a way to handle this properly in all cases.

Simply pasting a rect of the same color as the background behind everything will not work properly since that may actually change the bounding box of the design. Possibly the best way to deal with this might be to add some logic to catch this case that will advertise the --flip-gerber-polarity flag.

See #13.

Possible output resolution error with render command

Hey first of all thanks for making this amazing tool!
I am running into a possible issue with how the render command is outputting an image. I have a pcb project with dimensions of 91x37mm(3.57x1.46 inches). However when I run the gerbolyze render command on the gerber files (gerbolyze render top gerber_files output.png), I get a png file with a resolution of 96 pixels(W) by 235 pixels(H).
However according to the default resolution setting (10px/6mils) I would be expecting a width of 2427 pixels (1456 mils / 6 mils * 10 pixels). I was able to get around this by setting the fab resolution to .238 which left me with a width of 2421 which was closer to what I was expecting. I'll be using the new output with custom fab resolution but I just wanted to let you know and was wondering if I am just doing something completely wrong. I'll include the gerber folder and 2 outputs in-case you wanna look into it.

test_files1.zip

How do you use this with EasyEDA Gerber files

So, after finally getting gerbalyze template & paste to install and run in an Ubuntu Docker python3.10-pip environment (both using a full 'git' install and separately just using 'pip install'), I loaded the output files in several different Gerber viewers but the image I added in Inkscape didn't show up in the newly created Gerber file.

My steps were as follows:

  1. Export Gerber file from EasyEDA
  2. Run gerbalyze template --bottom easyeda.zip output.svg - No errors though a couple of warnings (see below)
  3. Open 'output.svg' in Inkskape and add/resize/move my image (a dithered high res B&W photo) to the bottom silkscreen level (called 'bottom-silk'). Save the image to output-image.svg
  4. Run gerbalyze paste easyeda.zip output-image.svg easyeda-image.zip - No errors though a couple of warnings (see below)
  5. Load 'easyeda-image.zip' into a Gerber viewer

The resulting top and bottom board views looked the same as the original -- i.e., no image added.
When I looked inside and compared the new and original zip files, I found that

  • Some layers in the original Gerber file were deleted (e.g., Gerber_TopAssemblyLayer.GTA, Gerber_DocumentLayer.GDL, Gerber_DrillDrawingLayer.GDD, How-to-order-PCB.txt -- presumably at least the last one is not really relevant)
  • The individual file sizes were all slightly smaller -- hopefully, no essential data was lost
  • No evidence of an image being added (as all files were smaller than their original counterparts)

Specifically, the files before looked like:

  Length      Date    Time    Name
---------  ---------- -----   ----
    12282  2023-04-18 21:47   Gerber_TopLayer.GTL
    34796  2023-04-18 21:47   Gerber_BottomLayer.GBL
   560729  2023-04-18 21:47   Gerber_TopSilkscreenLayer.GTO
    18684  2023-04-18 21:47   Gerber_BottomSilkscreenLayer.GBO
     3696  2023-04-18 21:47   Gerber_TopSolderMaskLayer.GTS
     2102  2023-04-18 21:47   Gerber_BottomSolderMaskLayer.GBS
     9819  2023-04-18 21:47   Gerber_TopPasteMaskLayer.GTP
      544  2023-04-18 21:47   Gerber_TopAssemblyLayer.GTA
      449  2023-04-18 21:47   Gerber_BoardOutlineLayer.GKO
     4293  2023-04-18 21:47   Gerber_DocumentLayer.GDL
    61079  2023-04-18 21:47   Gerber_DrillDrawingLayer.GDD
     1516  2023-04-18 21:47   Drill_PTH_Through.DRL
      700  2023-04-18 21:47   Drill_PTH_Through_Via.DRL
       76  2023-04-18 21:47   How-to-order-PCB.txt
---------                     -------
   710765                     14 files```
And after looked like:
```Archive:  Gerber_PCB4_2023-04-18-new.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
    11451  1980-01-01 00:00   Gerber_TopLayer.GTL
     3403  1980-01-01 00:00   Gerber_TopSolderMaskLayer.GTS
   549358  1980-01-01 00:00   Gerber_TopSilkscreenLayer.GTO
    10226  1980-01-01 00:00   Gerber_TopPasteMaskLayer.GTP
    37386  1980-01-01 00:00   Gerber_BottomLayer.GBL
     2059  1980-01-01 00:00   Gerber_BottomSolderMaskLayer.GBS
    18427  1980-01-01 00:00   Gerber_BottomSilkscreenLayer.GBO
      561  1980-01-01 00:00   Gerber_BoardOutlineLayer.GKO
     1656  1980-01-01 00:00   Drill_PTH_Through.DRL
      636  1980-01-01 00:00   Drill_PTH_Through_Via.DRL
---------                     -------
   635163                     10 files```

So in summary:
- Has anything been lost by deleting the listed files and by (slightly) shortening the existing remaining files
- Why wasn't the image added?
- Could the problem be that EasyEDA uses a different Gerber file format and/or layer naming/id than KiKaid?
- What do I need to do to make this work for EasyEDA Gerber files in general and my case in specific?


Note the warnings I got were as follows:
Gerbalyze Template:
```INFO:root:Layer top copper
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer top mask
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer top silk
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer top paste
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer bottom copper
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer bottom mask
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer bottom silk
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer mechanical outline
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer drill plated
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer drill nonplated
INFO:root:    Corresponding overlay layer not found. Skipping.
/gerbolyze/venv/lib/python3.10/site-packages/gerbonara-1.0.2-py3.10.egg/gerbonara/excellon.py:573: SyntaxWarning: /tmp/tmpcar8an7g/input/Drill_PTH_Through.DRL:19 "G90": G90 header statement found after end of header
  warnings.warn(f'{self.filename}:{self.lineno} "{self.line}": {msg}', SyntaxWarning)
/gerbolyze/venv/lib/python3.10/site-packages/gerbonara-1.0.2-py3.10.egg/gerbonara/excellon.py:573: SyntaxWarning: /tmp/tmpcar8an7g/input/Drill_PTH_Through_Via.DRL:15 "G90": G90 header statement found after end of header
  warnings.warn(f'{self.filename}:{self.lineno} "{self.line}": {msg}', SyntaxWarning)
(venv) root@08ef15a8041d:/EasyEDA-Pro/projects# gerbolyze template --bottom Gerber_PCB4_2023-04-18.zip Gerber_PCB4_2023-04-18-template2.svg
/gerbolyze/venv/lib/python3.10/site-packages/gerbonara-1.0.2-py3.10.egg/gerbonara/layers.py:789: UserWarning: Layer "bottom paste" not found. Found layers: top copper, top mask, top silk, top paste, bottom copper, bottom mask, bottom silk, mechanical outline
  warnings.warn(f'Layer "{side} {use}" not found. Found layers: {", ".join(side + " " + use for side, use in self.graphic_layers)}')
/gerbolyze/venv/lib/python3.10/site-packages/gerbonara-1.0.2-py3.10.egg/gerbonara/excellon.py:573: SyntaxWarning: /tmp/tmptpeao1um/input/Drill_PTH_Through.DRL:19 "G90": G90 header statement found after end of header
  warnings.warn(f'{self.filename}:{self.lineno} "{self.line}": {msg}', SyntaxWarning)
/jgerbolyze/venv/lib/python3.10/site-packages/gerbonara-1.0.2-py3.10.egg/gerbonara/excellon.py:573: SyntaxWarning: /tmp/tmptpeao1um/input/Drill_PTH_Through_Via.DRL:15 "G90": G90 header statement found after end of header
  warnings.warn(f'{self.filename}:{self.lineno} "{self.line}": {msg}', SyntaxWarning)```

Gerbalize paste warnings:
```INFO:root:Layer top copper
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer top mask
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer top silk
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer top paste
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer bottom copper
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer bottom mask
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer bottom silk
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer mechanical outline
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer drill plated
INFO:root:    Corresponding overlay layer not found. Skipping.
INFO:root:Layer drill nonplated
INFO:root:    Corresponding overlay layer not found. Skipping.
/gerbolyze/venv/lib/python3.10/site-packages/gerbonara-1.0.2-py3.10.egg/gerbonara/excellon.py:573: SyntaxWarning: /tmp/tmp89rwf6hx/input/Drill_PTH_Through.DRL:19 "G90": G90 header statement found after end of header
  warnings.warn(f'{self.filename}:{self.lineno} "{self.line}": {msg}', SyntaxWarning)
/gerbolyze/venv/lib/python3.10/site-packages/gerbonara-1.0.2-py3.10.egg/gerbonara/excellon.py:573: SyntaxWarning: /tmp/tmp89rwf6hx/input/Drill_PTH_Through_Via.DRL:15 "G90": G90 header statement found after end of header
  warnings.warn(f'{self.filename}:{self.lineno} "{self.line}": {msg}', SyntaxWarning)```

Thanks!

gerbolyze convert generates... nothing, or a bunch of identical broken files?

I'm trying to get the protoboard generator working again, and I've mostly succeeded, but I'm running into something I haven't managed to chase down in the bowels of gerbolyze: the gerber files made seem to be broken or blank. I need help pinpointing the issue. For an example, I will use a file generated by generate_protoboards.py, called output_protoboards/svg/tht_normal_pitch100mil_large_holes/no_mounting_holes/tht_normal_pitch100mil_large_holes_30x40.svg (referred from now on as proto.svg)

When I run the command that export_protoboards.py would run, I get a pile of tiny, identical gerber files:

(venv) g@hamilton:~/programs/gerbolyze$ python3 -m gerbolyze convert --log-level=info --pattern-complete-tiles-only --use-apertures-for-patterns proto.svg proto_out
Warning (in fontdb:207): Failed to load a font face 0 from '/home/g/.fonts/Sleepy Hollow 3.ttf' cause font doesn't have a family name.
(venv) g@hamilton:~/programs/gerbolyze$ md5sum proto_out/*
ba41d73a010d9e5e62ac383554027b38  proto_out/proto-B.Cu.gbr
ba41d73a010d9e5e62ac383554027b38  proto_out/proto-B.Mask.gbr
ba41d73a010d9e5e62ac383554027b38  proto_out/proto-B.Paste.gbr
ba41d73a010d9e5e62ac383554027b38  proto_out/proto-B.SilkS.gbr
ba41d73a010d9e5e62ac383554027b38  proto_out/proto-Edge.Cuts.gbr
ba41d73a010d9e5e62ac383554027b38  proto_out/proto-F.Cu.gbr
ba41d73a010d9e5e62ac383554027b38  proto_out/proto-F.Mask.gbr
ba41d73a010d9e5e62ac383554027b38  proto_out/proto-F.Paste.gbr
ba41d73a010d9e5e62ac383554027b38  proto_out/proto-F.SilkS.gbr
ba41d73a010d9e5e62ac383554027b38  proto_out/proto.nonplated.drl
ba41d73a010d9e5e62ac383554027b38  proto_out/proto.plated.drl
(venv) g@hamilton:~/programs/gerbolyze$ cat proto_out/proto-B.Cu.gbr 
G04 Gerber file generated by Gerbonara*
%MOMM*%
%FSLAX46Y46*%
%IPPOS*%
G75
%LPD*%
%AMGNC*
1,1,$1,0,0,-57.29578X$4*
1,0,$2,0,0,0*
21,0,$2,$3,0,0,$4X-57.29578*
%
%AMGNR*
21,1,$1,$2,0,0,$5X-57.29578*
1,0,$3,0,0,0*
21,0,$3,$4,0,0,$5X-57.29578*
%
%AMGNO*
21,1,$1,$2,0,0,$5X-57.29578*
1,1,$2,$1/2,0,$5X-57.29578*
1,1,$2,(0-$1)/2,0,$5X-57.29578*
1,0,$3,0,0,0*
21,0,$3,$4,0,0,$5X-57.29578*
%
%AMGNP*
5,1,$2,0,0,$1,$3X-57.29578*
1,0,$4,0,0,0*
%
%ADD10C,0.05*%
M02*

This looks incorrect. I'd at least expect some of the files to be different from each other...

The source svg file is here: proto

Various dependency versions I've arrived at by trial and error:

(venv) g@hamilton:~/programs/gerbolyze$ pip3 show gerbonara
Name: gerbonara
Version: 0.13.0
Summary: Tools to handle Gerber and Excellon files in Python
Home-page: https://gitlab.com/gerbolyze/gerbonara
Author: jaseg, XenGi
Author-email: [email protected]
License: 
Location: /home/g/programs/gerbolyze/venv/lib/python3.11/site-packages
Requires: click
Required-by: 
(venv) g@hamilton:~/programs/gerbolyze$ usvg --version
0.27.0
(venv) g@hamilton:~/programs/gerbolyze$ resvg --version
0.27.0
(venv) g@hamilton:~/programs/gerbolyze$ python --version
Python 3.11.4

Could use a pointer or two! Even if it's just a known-good-set of python, usvg, resvg, gerbonara, and whatever else dependency version numbers.

Possible Windows (or alternately web) version?

Hi!

I've been following the project for a while now and I love the results you are getting. Dithering rocks.

I see that there is a macOS build via homebrew. Is there an easy way to run this in Windows without resorting to a docker container or something similar? A way to build this in windows would be great, or something akin to homebrew, or even just a little portable app. I know a webUI version is far more complicated as well but I've seen a lot of projects in this space also use those so that might be looking into.

Thank you so much for your work so far! The results are gorgeous.

inverting gerber

Treatment of SVG from which black background and white letters freezes.
Tried
svg-flatten --format gerber outfile004_inv.svg outfile004_inv.gbr

I did not find the key to invert SVG when converting in gerber

Crashes trying to vetorize to empty gerber file / silkscreen layer

When trying to add the image to an empty silkscreen layer the program crashes.

Traceback (most recent call last):
  File "/home/-/.local/bin/gerbolyze", line 32, in <module>
    gerbolyze.process_gerbers(args.source, args.target, args.image, args.side, args.layer, args.debugdir)
  File "/home/-/.local/lib/python3.7/site-packages/gerbolyze.py", line 343, in process_gerbers
    out = paste_image(tgrb, ogrb, source_img, [subtract], debugdir=debugdir, status_print=lambda *args: print(*args, flush=True))
  File "/home/-/.local/lib/python3.7/site-packages/gerbolyze.py", line 208, in paste_image
    status_print=lambda *args: status_print('   ', *args))
  File "/home/-/.local/lib/python3.7/site-packages/gerbolyze.py", line 234, in plot_contours
    aperture = list(layer.apertures)[0]
IndexError: list index out of range

As a workaround I added some text before processing with gerbolyze and removed it afterwards.

Problem with SVG image containing hollow cutouts

I am trying to use svg-flatten to convert SVG images to kicad footprints (silkscreen graphics).
My drawings contain multiple closed shapes with cutouts but these are rendered as plain filled areas, here are original image from inkscape and result in kicad:
original_image
kicad_result

Am I missing something or do I need specific preparation of the SVG file ?

The command line I use is:
svg-flatten --format kicad --sexp-layer F.SilkS --sexp-mod-name tentacles_02 tentacles2.svg ../pcb/drawings.pretty/tentacles_02.kicad_mod

Thank you very much 😀

Loss of one vertex in each element when converting in KLayout

Prepared Gerber from SVG
svg-flatten --format gerber in.svg outfile.gbr

And imported outfile.gbr in KLayout, in KLayout wiely that each element disappeared one vertex.
With gerbera files received in other ways such an error is not selected.

I did not find a way to invert svg

Conversion results have no data except LPD/LPC by svg-flatten command with --flatten option

I use the svg-flatten command with the options of --force-svg --flatten -o gerber example.svg example.gtl to convert svg to gerber file. The files are paste below.
The Gerber content is weird as below. If I remove the option of --flatten, the output gerber is OK. If I want to flatten the svg, it will fail. Is there something I am missing?
%FSLAX46Y46*%
%MOMM*%
%LPD*%
G01*
%ADD10C,0.050000*%
D10*
%LPD*%
%LPC*%
%LPD*%
%LPD*%
%LPD*%
%LPC*%
%LPD*%
%LPD*%
%LPD*%
%LPC*%
%LPD*%
%LPD*%
%LPD*%
%LPC*%
%LPD*%
%LPD*%
%LPD*%
%LPC*%
%LPD*%
%LPD*%
%LPD*%
M02*
example.svg:
example
example-usvg-output.svg:
example-usvg-output

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.