INTI-CMNB / KiBot

KiCad automation utility
GNU Affero General Public License v3.0
552 stars 65 forks source link

[FEATURE]SVG support for Logo #383

Closed N0cynym closed 5 months ago

N0cynym commented 1 year ago

Is your feature request related to a problem? Please describe.

ERROR:In section 'bom_html' (bom): Only PNG images are supported for the logo (kibot - error.py:40)

Describe the solution you'd like Supporting vector graphics as logo in bill of materials.

Describe alternatives you've considered Automatic sizing of high resolution png.

I have a 1043x919 px png and use convert to resize it. The problem here is that it looks bad after resize.

Additional context I do currently create one PCB documentation with pdfunite and export my generated xlsx spreadsheet with soffice. Unfortunately just png is supported which is let the logo look not so nice compared to the rest of the bom. It's just a request if this is possible.

N0cynym commented 1 year ago

Ok I found this commit https://github.com/INTI-CMNB/KiBot/commit/1dea3970bc063340d17251ecc8a11e860fb51f31 and will test to scale my logo.

N0cynym commented 1 year ago

So I could not work out how the scaling is working correctly. logo_scale: -10 removes my png

Which logo is used in default?

set-soft commented 1 year ago

Hi @N0cynym !

So I could not work out how the scaling is working correctly. logo_scale: -10 removes my png

What do you expect using a negative scale? How does your logo look using the default scale (2)? Too big? Use 1 or less than 1. Too small? Use more than 2.

But note that (as documented) not all spreadsheet software applies the scale. Also note that the size you get is dependent on the spreadsheet. So you must experiment it for the software you use.

Which logo is used in default?

The KiBot logo, a 370x200 PNG embedded in the code.

About adding support for SVG: This can be done, but for this KiBot must convert the image to PNG, I don't see any advantage of doing this inside KiBot.

N0cynym commented 1 year ago

If I use the scale >1 the logo is to big.

A negative scale will remove the logo.

Trying a positive scale <1 and >0 give me:

ERROR:In section 'bom_xlsx' (bom): Optionlogo_scalemust be a number notstring(kibot - error.py:40)

set-soft commented 1 year ago

Are you using . as decimal separator? I modified the XLSX test 7 like this:

# Example KiBot config file
kibot:
  version: 1

outputs:
  - name: 'bom_internal'
    comment: "Bill of Materials in HTML format"
    type: bom
    dir: BoM
    options:
      format: XLSX
      xlsx:
        logo: docs/images/bot.png
        logo_scale: 0.1
        col_colors: false

And worked perfectly, I got it scaled to a good size, the original PNG looks huge.

N0cynym commented 1 year ago

Thanks for your look into it.

It's working and my fault was logo_scale: '0,5'

Could you make a note into the README.md what the default size/resolution is of the used logo? This will help if you want to use your own logo.

Question: So it's impossible to embed a svg vector graphics in html and xlsx formats?

set-soft commented 1 year ago

Hi @N0cynym !

YAML numbers use a point as decimal separator, like in most programming languages this isn't affected by the user locale. Also note that using quotes you are converting it to a string.

About the default: is already documented:

Here the docs says the value must be a number, and its default is 2.

About SVG: For the HTML could be possible, but not for the XLSX. I don't see much advantage in doing it for the HTML, in particular knowing that SVGs are problematic.

What KiBot could do is convert the SVG to PNG, but this is really low priority. I always wanted to create an output to convert image formats, so it could help in the future

N0cynym commented 1 year ago

Ok thank you very much! 👍

I'll have a look into it if I see that a new feature is availible.

set-soft commented 5 months ago

Ok, the above patch adds support for SVGs. Is a good starting point, please report any issue.