X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com X-Virus-Scanned: Debian amavisd-new at mail.linetec.nl Content-Type: multipart/mixed; boundary="------------JaY2ReLp3DkuyskBqhftRlRF" Message-ID: <6877754c-dcb7-db34-dd39-419de060ad7a@linetec.nl> Date: Sun, 1 Oct 2023 15:11:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 To: GEDA mailing list <geda-user AT delorie DOT com> Content-Language: en-US From: "Richard Rasker (rasker AT linetec DOT nl) [via geda-user AT delorie DOT com]" <geda-user AT delorie DOT com> Subject: [geda-user] PCB silk layer image script Reply-To: geda-user AT delorie DOT com This is a multi-part message in MIME format. --------------JaY2ReLp3DkuyskBqhftRlRF Content-Type: multipart/alternative; boundary="------------4X9plFyBWMV0zFbIvbPm7b06" --------------4X9plFyBWMV0zFbIvbPm7b06 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi all, Every now and then, questions pop up about converting a logo or other image into a silk screen element, and many answers involve a more or less manual process using Inkscape combined with pstoedit. Also see the thread 'PCB jpg to silkscreen' here, starting 7 November 2019. As I found I had to look up the details again every time, I decided to create a script by the name of pcbsilk that automates most of the process -- see attached file. It requires imagemagick, potrace and pstoedit to work, and accepts several common image formats (JPG, PNM as well as EPS). How it works: It first checks whether a width is specified for the resulting silk layer element. If no width is specified, it defaults to 40 mm. Then it checks if the input file is an EPS file already; if not, it uses imagemagick's convert to convert the image to PBM format, which is then fed to potrace to create an EPS file. The resulting EPS file is then converted into a PCB silkscreen element using pstoedit. But even though it works sort of OK, there are a few annoying things that I haven't been able to fix (apart from several smaller refinements): - When specifying width in millimeters, things work up to 73 millimeters but throw a sort of overflow error above that value: $ pcbsilk -W 74mm testlogo.jpg double free or corruption (!prev) /home/richard/scripts/pcbsilk: line 36: 15520 Aborted (memory dumped) pstoedit -q -f "pcbfill" -ssp $silkname.eps $silkname.pcb The actual size itself does not seem to cause the problem, as inch sizes (e.g. -W 74in) work just fine. So it seems that it is the millimeter units that somehow have a limited range -- not in potrace (where the width is specified), but in pstoedit. I could of course work around the problem by converting millimeter sizes into inches before calling pstoedit, so I think that's what I'll do. - Specifying a width of course also does not work for EPS files, as any scaling is done before conversion to EPS. Is there a way to specify width in pstoedit? Or is there an easy tool to scale an EPS element without having to parse the file myself? - The pstoedit command produces a PCB file with default workspace dimensions (6000 x 5000 mil here), with the silk image at the bottom left. Is it possible to (temporarily) adjust this default to fit the image size? Thanks for comments, corrections and of course solutions! Best regards, Richard Rasker --------------4X9plFyBWMV0zFbIvbPm7b06 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body> <p>Hi all,</p> <p>Every now and then, questions pop up about converting a logo or other image into a silk screen element, and many answers involve a more or less manual process using Inkscape combined with pstoedit. Also see the thread 'PCB jpg to silkscreen' here, starting 7 November 2019.<br> </p> <p>As I found I had to look up the details again every time, I decided to create a script by the name of pcbsilk that automates most of the process -- see attached file. It requires imagemagick, potrace and pstoedit to work, and accepts several common image formats (JPG, PNM as well as EPS).<br> </p> <p>How it works:<br> </p> <p>It first checks whether a width is specified for the resulting silk layer element. If no width is specified, it defaults to 40 mm.</p> <p>Then it checks if the input file is an EPS file already; if not, it uses imagemagick's convert to convert the image to PBM format, which is then fed to potrace to create an EPS file. The resulting EPS file is then converted into a PCB silkscreen element using pstoedit.<br> </p> <p>But even though it works sort of OK, there are a few annoying things that I haven't been able to fix (apart from several smaller refinements):</p> <p>- When specifying width in millimeters, things work up to 73 millimeters but throw a sort of overflow error above that value:</p> <blockquote> <p><span style="font-family:monospace"><span style="color:#000000;background-color:#ffffff;">$ pcbsilk -W 74mm testlogo.jpg </span><br> double free or corruption (!prev) <br> /home/richard/scripts/pcbsilk: line 36: 15520 Aborted (memory dumped) pstoedit -q -f "pcbfill" -ssp $silkname.eps $silkname.pcb<br> </span></p> </blockquote> <p>The actual size itself does not seem to cause the problem, as inch sizes (e.g. -W 74in) work just fine. So it seems that it is the millimeter units that somehow have a limited range -- not in potrace (where the width is specified), but in pstoedit. I could of course work around the problem by converting millimeter sizes into inches before calling pstoedit, so I think that's what I'll do.<br> </p> <p>- Specifying a width of course also does not work for EPS files, as any scaling is done before conversion to EPS. Is there a way to specify width in pstoedit? Or is there an easy tool to scale an EPS element without having to parse the file myself?</p> <p>- The pstoedit command produces a PCB file with default workspace dimensions (6000 x 5000 mil here), with the silk image at the bottom left. Is it possible to (temporarily) adjust this default to fit the image size?<br> </p> <p>Thanks for comments, corrections and of course solutions!</p> <p>Best regards,</p> <p>Richard Rasker<br> </p> </body> </html> --------------4X9plFyBWMV0zFbIvbPm7b06-- --------------JaY2ReLp3DkuyskBqhftRlRF Content-Type: text/plain; charset=UTF-8; name="pcbsilk" Content-Disposition: attachment; filename="pcbsilk" Content-Transfer-Encoding: base64 IyEvYmluL2Jhc2gKCmlmIFsgIiQxIiA9ICItPyIgXSB8fCBbICIkMSIgPSAiLWgiIF0gfHwg WyAiJDEiID0gIi0taGVscCIgXQp0aGVuCiAgIGVjaG8gIlVzYWdlOiAgJDAgWy1XIHdpZHRo XSBpbWFnZSIKICAgZWNobyAtZSAiXHRJbWFnZSBpcyBhbnkgaW1hZ2UgZmlsZSBvciBFUFMg ZmlsZSIKICAgZWNobyAtZSAiXHRVc2UgLVcgc3dpdGNoIHRvIHNwZWNpZnkgd2lkdGgiCiAg IGVjaG8gLWUgIlx0V2lkdGggaXMgc3BlY2lmaWVkIGluIGluY2hlcyAoc3VmZml4Om5vbmUg b3IgaW4pIG9yIG1pbGxpbWV0ZXJzIChzdWZmaXg6IG1tKSIKICAgZWNobyAtZSAiXHREZWZh dWx0IHdpZHRoIGlzIDQwIG1tIgogICBleGl0IDEKZmkKCiMgQ2hlY2sgaWYgd2lkdGggaXMg c3BlY2lmaWVkCmlmIFsgIiQxIiA9ICItVyIg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