Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE]SVG support for Logo #383

Closed
N0cynym opened this issue Feb 1, 2023 · 9 comments
Closed

[FEATURE]SVG support for Logo #383

N0cynym opened this issue Feb 1, 2023 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@N0cynym
Copy link

N0cynym commented Feb 1, 2023

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 N0cynym added the enhancement New feature or request label Feb 1, 2023
@N0cynym
Copy link
Author

N0cynym commented Feb 1, 2023

Ok I found this commit 1dea397 and will test to scale my logo.

@N0cynym
Copy link
Author

N0cynym commented Feb 1, 2023

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
Copy link
Member

set-soft commented Feb 1, 2023

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
Copy link
Author

N0cynym commented Feb 1, 2023

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): Option logo_scalemust be a number notstring (kibot - error.py:40)

@set-soft
Copy link
Member

set-soft commented Feb 1, 2023

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
Copy link
Author

N0cynym commented Feb 1, 2023

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
Copy link
Member

set-soft commented Feb 2, 2023

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:

  • logo_scale: [number=2] Scaling factor for the logo. Note that this value isn't honored by all spreadsheet software.

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
Copy link
Author

N0cynym commented Feb 2, 2023

Ok thank you very much! 👍

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

set-soft added a commit that referenced this issue Mar 30, 2024
@set-soft
Copy link
Member

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

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

No branches or pull requests

2 participants