Skip to content

Conversation

vroland
Copy link

@vroland vroland commented Apr 28, 2025

The native kicad-cli now offers a way to render board images from the CLI . Since some users (including me) had some dependency issues with PcbDraw, this PR adds the option to use kicad-cli for board images by adding a --renderer switch to kikit present.

Kicad-cli is not perfect unfortunately, as there is no way currently to output appropriately sized images directly. As a workaround, this uses image magick to crop the images generated by KiCad.

Let me know if you're willing to upstream this and if there are any changes to make.


kicadCli = shutil.which("kicad-cli")
if not kicadCli:
raise RuntimeError("kicad-cli needs to be installed in order to render boards")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise RuntimeError("kicad-cli needs to be installed in order to render boards")
if sys.platform == "darwin":
kicadCli = "/Applications/KiCad/KiCad.app/Contents/MacOS/kicad-cli"
else:
raise RuntimeError("kicad-cli needs to be installed in order to render boards")

kicad-cli tends not to be on the PATH on MacOS

@yaqwsx
Copy link
Owner

yaqwsx commented May 1, 2025

Hi! I have plans to revisit PCBDraw and actually use the rendering facilities in Kicad-cli. However, lately, I have struggled to find enough time to make larger changes to my tools. Overall, I would prefer fixing PcbDraw. However, given the circumstances, I think your solution is appropriate and I will be happy to merge the PR.

I see two minor problems we need to resolve in your PR:

  • In my other projects, I run into the issue that locating the kicad-cli binary might be challenging (especially on Windows). I usually end up with a function that tries a bunch of heuristics. But maybe there is a better way?
  • I would prefer not to depend on ImageMagick. I think that we do all the transformation you need with Python-native libraries that will install automatically with KiKit.

@putyn
Copy link
Contributor

putyn commented Aug 9, 2025

I also had issues installing pcbdraw with the latest version of kikit, due to the pcbnewtransition package, that is when I found @vroland fork implementing a new render engine. My OS is Windows and while the kicad-cli executable was found no problem, even with ImageMagick installed the code found a convert utility under Windows for converting FAT to NTFS volumes definitely not the convert needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants