Bitmap2component (almost)empty output file


#1

I’m having some difficulty using this tool. It’s output appears to be lacking drawing data.
When attempting to convert an Arduino logo, this is all I get:

(module LOGO (layer F.Cu)
(at 0 0)
(fp_text reference “G***” (at 0 0) (layer F.SilkS) hide
(effects (font (thickness 0.3)))
)
(fp_text value “LOGO” (at 0.75 0) (layer F.SilkS) hide
(effects (font (thickness 0.3)))
)
(fp_poly (pts (xy 3.175000 2.159000) (xy -3.175000 2.159000) (xy -3.175000 -2.159000) (xy 3.175000 -2.159000) (xy 3.175000 2.159000) )(layer F.SilkS) (width 0.010000)
)
)

That’s the entire output file… 405 bytes.
The original image is in .png format (9.2Kb). No scaling was used in the conversion.

Any ideas ?


#2

Probably need to adjust the threshold value. What you see in the tab “Black&White picture” is what gets output.

ETA: Hmm, “negative” mode seem to produce nothing, but “Normal” works.


#3

Thanks, but I tried all all options. Still no luck.

Settings are:
Format: Pcbnew
Options: Normal
Threshold: 50
Board Layer: Front Silk

All tabs (Original, Greyscale, Black&White) show the same image and show it correctly.


#4

If you post the file, I could try it.


#5

Sure! Here it is…


#6

Strange, appears to be a bug. I tried a random png file on my PC and it worked ok, the file you posted plus an Arduino logo I just downloaded don’t work. I can’t see anything particular about the files that would cause a problem.

As a sanity check, try this file

ETA: It appears that Bitmap2Component doesn’t always work correctly with transparent backgrounds. Painting the transparent parts with a color produces output.


#7

Got PLENTY of drawing data on that one.

I also noticed that no file gets saved at all if you don’t specifically add the ‘.kicad_mod’ to the end of the file name for saving.

Glad you see strangeness as well… At least I know it’s not me just going nuts !


#8

OH…
I’ll try removing the transparency.


#9

Has to be the transparent background !
I filled-in the background with white (GIMP) and got 14.6Kb output file.


#10

bitmap2component makes a footprint or am i confused again?

If so you could also use this svg file or use my cleaned up svg and use svg2mod
Just download the file, open it in inkscape and put the logo on the appropriate layer (the cleaned up file already does that for you. Maybe remove the TM mark it is quite small)

Remark on my linked svg: don’t worry about the pixelated google drive preview. In reality it is a vector drawing but the google preview converts it to raster graphics. (use the download button to download it)

Download the file and export the footprint with: (the original is about 10x10mm you can scale it with the option -f. if you want a 20 mm footprint simply add -f 2.0 to the command)
python svg2mod.py --format pretty -p 0.1 -i [absolute path]/Arduino_Logo_silk_10x10mm.svg -o [absolute path]/Arduino_Logo_silk_10x10mm


#11

Ya know, Rene…
I’m new to all this, but I do believe it does make footprints.

I would rather be able to use .SVGs directly and Inkscape is powerful, but unless a box the size of the image is created and placed on the very bottom layer, it always saves as transparent background. And I didn’t see .SVG as one of the formats supported by bitmap2component.

Could you offer a step-by-step on using svg2mod ?
Would really be helpful.

Thanks !


#12

It also appears that, at least with a white background, one has to specify that the Options: section of bitmap2component has to be set as ‘Negative’ in order to avoid getting the entire background produced as well.


#13

svg2mod is a standalone python tool. It needs to be run from a termainl (console, command-line, whatever you want to call it)
Make sure you have python installed.
(for linux just install python with you package manager. Version 2.7.x and 3.x should be ok for svg2mod)

go to the github page of svg2mod
select clone or download and download as zip
unpack the zip (and remember where you placed it.)

download the svg file i provided above. (remember where you placed it. The simplest for you would be to place it in the directory of svg2mod)

Now my lack of knowledge about windows becomes apparent.
Here a explanation how to rund python scripts under windows: http://pythoncentral.io/execute-python-script-file-shell/
open a terminal (cmd in windows i think)
Navigate to the directory holding svg2mod (there is a svg2mod.py file) The cd commad is used to change the directory. ls to few the contents (dir in windows)
If you are in the correct directory and have the svg file in the same directory simply enter the following:
Linux: python ./svg2mod.py --format pretty -p 0.1 -i ./Arduino_Logo_silk_10x10mm.svg -o ./Arduino_Logo_silk_10x10mm
Windows: [path to the python binary] ./svg2mod.py --format pretty -p 0.1 -i ./Arduino_Logo_silk_10x10mm.svg -o ./Arduino_Logo_silk_10x10mm
[path to the python binary] depends on your installation.
A standard installation puts it under: C:\Python27\python.exe

This would produce a 10x8mm logo on f.silks (because that is how i created the svg file)
If you want a different size simply add a scaling factor (-f [scale])
example to get a 5x4mm logo:
python ./svg2mod.py --format pretty -f 0.5 -p 0.1 -i ./Arduino_Logo_silk_10x10mm.svg -o ./Arduino_Logo_silk_10x10mm

If you want the logo on another layer open the svg file in inkscape and either rename the layer it is on or move it to another layer. (I provided you with the layers for mask and copper already.) To move stuff to another layer: select it. Right click->move to layer. Select the layer you want.

Look in the document properties. There you can set the background color. (Normally it is transparent as you already discovered)
The document properties are under file->document properties

(again replace python with [path to python binary] on windows)


#14

I have tried that several times.
Setting the background to white and opacity to 100% (ffffffff) still produces a transparent background.


#15

That could be a bug in inkscape.


#16

check out this extension https://github.com/badgeek/svg2shenzhen-next

(im the author)