-
-
Notifications
You must be signed in to change notification settings - Fork 455
chore(color): helper script to generate PNG icons from SVG source #6768
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
Conversation
|
Have you actually tried running this yet? As you've not committed the changes to the PNG files, which should be done at the same time as the PR, especially so the effect on the firmware can be seen. This is also somewhat of a duplicate of what Phil did in #6762 and what I started to work on on Monday here https://github.com/EdgeTX/edgetx/tree/pfeerick/alternate-convert-script. I planned on trying out resvg as Pillow/cairosvg wasn't suitable (doesn't play well with complex SVG files), inkscape is a heavy dependency for one "small" task, and ImageMagick uses librsvg anyway... |
|
@pfeerick solution is preferred as it only keeps one set of icons sizes (for 480x272). Generating other sizes is done by applying a scaling factor making it easier to alter the scale or create new ones. |
@pfeerick can I contribute your branch? |
Scaling factor ensures every icon is always the right size, manually having to enter every size is error prone and more work. |
|
Ok then, so if you are both happy with that, I'll close #6762, close this PR, open a PR for what I have presently, and we can make any changes necessary there. Presently it does not require any CSV file, and adding a new resolution is trivial as it would just need another scaling factor added (one line change), and then it can generate just that resolution or regenerate all. But let's continue the discussion in a new PR if this is how you want to proceed. |
No problem with that, as I wrote let's go with scaling. |
Of course! ;) I'm sure it can be optimised further, still, and doesn't do any cleanup or other checks yet, so that can still be added. Also probably need to lock the version of rsvg used so always using a consistent version... Feel free to give me a todo / wishlist in #6772, and we'll see where it leads. |

Summary of changes:
Usage: png-radio-fw.sh [ --check | --update | --build | --help]
Modes:
--check Verify that PNGs exist for all SVGs in 320x240, 480x272, 800x480.
Prints to console missing files.
--update Scan SVGs under img-src and produce CSV of PNG dimensions for 320x240, 480x272, 800x480
Output: /Users/jimb40/GitHub/JimB40/edgetx/tools/png_radio_fw_list.csv
Missing PNGs are printed to console.
--build Read /Users/jimb40/GitHub/JimB40/edgetx/tools/png_radio_fw_list.csv and generate PNGs in /Users/jimb40/GitHub/JimB40/edgetx/tools/../radio/src/bitmaps
- Target directories DIR are taken from CSV header (cols 2-4)
- Output PNGs placed in DIR folders (e.g., 320x240, 480x272, 800x480)
- Files starting with 'mask_' rendered with background color (white). Others remain transparent.