GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lv_img_conv_py: minimal python port of node module by NeroBurner · Pull Request #1863 · InfiniTimeOrg/InfiniTime

Conversation

@NeroBurner

@NeroBurner NeroBurner commented Sep 21, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Create a minimal python port of the node.js module lv_img_conv. Only
the currently in use color formats CF_INDEXED_1_BIT and
CF_TRUE_COLOR_ALPHA are implemented.

Output only as binary with format ARGB8565_RBSWAP (and ARGB8888 for debugging).

This is enough to create the resources-1.13.0.zip.

In the simulator the pinecone in Casio is visible, and the navigation symbol is visible as well in the simulator when the resource zip is loaded

The new lv_img_conv.py script needs python3-pil python module as runtime dependency.
The runtime dependency is added to the docker container image.

InfiniSim_2023-09-21_230253_casio
InfiniSim_2023-09-21_230304_nav

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

clach04 reacted with thumbs up emoji tausen reacted with hooray emoji
All reactions
  • 👍 1 reaction
  • 🎉 1 reaction
@NeroBurner NeroBurner changed the title lv_img_conv_py: minimal python port of node module draft: lv_img_conv_py: minimal python port of node module Sep 21, 2023
@github-actions

github-actions Bot commented Sep 21, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Build size and comparison to main:

Section Size Difference
text 376784B -16B
data 940B 0B
bss 63420B 0B
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@NeroBurner NeroBurner mentioned this pull request Sep 22, 2023
Build fails at targetlittlefs-do InfiniTimeOrg/InfiniSim#121
Closed
@NeroBurner
NeroBurner marked this pull request as draft September 25, 2023 14:43
@NeroBurner NeroBurner changed the title draft: lv_img_conv_py: minimal python port of node module lv_img_conv_py: minimal python port of node module Sep 25, 2023
@NeroBurner

NeroBurner commented Sep 28, 2023

Copy link
Copy Markdown
Contributor Author

I've fixed part of the differences between the original nodejs script and the python based port. It was the usage of round() in the helper function classify_pixel().
Python3 implements "propper" "banker's rounding" by rounding to the nearest
even number. Javascript rounds to the nearest integer as we've learned in school.
To have the same output as the original JavaScript implementation add a custom
rounding function, which does "school" rounding (to the nearest integer).


After that there is still a difference between the binaries. Therefore I implemented the ARGB8888 binary-output-format to compare the rgba values read by the scripts from the png.

./lv_img_conv.js pine_logo.png --force --output-file pine_small_js_8888.bin --color-format CF_TRUE_COLOR_ALPHA --output-format bin --binary-format ARGB8888
xxd pine_small_js_8888.bin > pine_small_js_8888.bin.hex

Same with the current python port

python3 lv_img_conv.py  --force --output-file pine_small_js_8888.bin --color-format CF_TRUE_COLOR_ALPHA --output-format bin --binary-format ARGB8888
xxd pine_small_py_8888.bin > pine_small_py_8888.bin.hex

Uploaded the hex files for comparison:

  • pine_small_js_8888.bin.hex
  • pine_small_py_8888.bin.hex

Comparing the two hex files shows there are differences in how the PNG file is read in (because ARGB8888 just outputs the read rgba values)
Screenshot_20230928_222816

The first different pixel is at x==10, y==0. Looking at that pixel nodejs returns rgba=[19, 19, 19, 26] compared to python rgba=[20, 20, 20, 26]

Opened the pine-logo.png in Gimp and it shows the same values as the python script

gimp rgba color values

This off-by-one input differences results in some differences in the normal ARGB8565_RBSWAP output binary format as well.
As the difference is small and I believe the value from Gimp I'd keep the python script as it is (as I don't know how to "fix" it to be like the node input)


The only difference for the navigation0.png and navigation1.png files is the hard coded color palette. The remaining bits are the same for nodejs and python implementation

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@FintasticMan FintasticMan mentioned this pull request Sep 29, 2023
infinitime/infinitime-build:latest fails to build #1868
Closed
1 task done
@NeroBurner
NeroBurner force-pushed the lv_img_conv_py branch 2 times, most recently from fa92ff9 to 4edfbae Compare October 18, 2023 20:11
@NeroBurner
NeroBurner marked this pull request as ready for review October 18, 2023 20:15
@NeroBurner
NeroBurner requested a review from a team October 18, 2023 20:15
@NeroBurner NeroBurner added the maintenance Background work label Oct 18, 2023
mark9064
mark9064 reviewed Oct 18, 2023
View reviewed changes

@mark9064 mark9064 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great overall, performance is a lot better as well. Haven't tested on hardware but according to your earlier tests I trust the output
Mostly code cleanliness suggestions/doc suggestions, only architectural one is whether you want to import the file directly or run it as a subprocess

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/resources/generate-img.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/resources/lv_img_conv.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/resources/lv_img_conv.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread doc/buildAndProgram.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .github/workflows/main.yml Outdated
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install python3-pil

@mark9064 mark9064 Oct 18, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "Install resource build dependencies" would be better?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@NeroBurner NeroBurner Oct 19, 2023

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once the docker file is updated this install should be removed as it is already done in the used docker image 🤔

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@NeroBurner NeroBurner Oct 26, 2023

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed as recommended, probably should remove in future 🤔
but keeping it for now to allow a smooth CI until docker image is updated

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/resources/lv_img_conv.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/resources/lv_img_conv.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/resources/lv_img_conv.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/resources/lv_img_conv.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/resources/lv_img_conv.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

NeroBurner
NeroBurner commented Oct 19, 2023
View reviewed changes

@NeroBurner NeroBurner left a comment

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

partial fixes, gonna do the rest at a later time

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread .github/workflows/main.yml Outdated
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install python3-pil

@NeroBurner NeroBurner Oct 19, 2023

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once the docker file is updated this install should be removed as it is already done in the used docker image 🤔

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread doc/buildAndProgram.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/resources/lv_img_conv.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/resources/lv_img_conv.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/resources/lv_img_conv.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/resources/lv_img_conv.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/resources/lv_img_conv.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/resources/lv_img_conv.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

JF002
JF002 approved these changes Oct 26, 2023
View reviewed changes

@JF002 JF002 left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm far from a Python expert, so I trust you on that regard 👍

This scripts makes the setup of the build environment much easier and it works fine on my setup and in the build Docker container so... LGTM :-)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
NeroBurner added 2 commits October 26, 2023 22:12
@NeroBurner
lv_img_conv_py: minimal python port of node module
b260f00
Create a minimal python port of the node.js module `lv_img_conv`. Only
the currently in use color formats `CF_INDEXED_1_BIT` and
`CF_TRUE_COLOR_ALPHA` are implemented.

Output only as binary with format `ARGB8565_RBSWAP`.

This is enough to create the `resources-1.13.0.zip`.

Python3 implements "propper" "banker's rounding" by rounding to the nearest
even number. Javascript rounds to the nearest integer.
To have the same output as the original JavaScript implementation add a custom
rounding function, which does "school" rounding (to the nearest integer)

Update CMake file in `resources` folder to call `lv_img_conf.py` instead of
node module.

For docker-files install `python3-pil` package for `lv_img_conv.py` script.
And remove the `lv_img_conv` node installation.

---

gen_img: special handling for python lv_img_conv script

Not needed on Linux systems, as the shebang of the python script is read
and used. But just to be sure use the python interpreter found by CMake.
Also helps if tried to run on Windows host.

---

doc: buildAndProgram: remove node script lv_img_conv mention

Remove node script `lv_img_conv` mention and replace it for
runtime-depency `python3-pil` of python script `lv_img_conv.py`.
@NeroBurner
CI: install build resource dependency python3-pil package
672e305
Used by script `lv_img_conv.py`, should be provided by docker image, but
until then explicitly install in workflow.
@NeroBurner
NeroBurner force-pushed the lv_img_conv_py branch from b511b93 to 672e305 Compare October 26, 2023 20:16
@NeroBurner

NeroBurner commented Oct 26, 2023

Copy link
Copy Markdown
Contributor Author

code review incorporated, squashed and pushed, gonna merge as soon as possible

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@NeroBurner

NeroBurner commented Oct 26, 2023

Copy link
Copy Markdown
Contributor Author

User MorsMortium informed me on Matrix, that there is a full port available at https://github.com/W-Mai/lvgl_image_converter

Still using this minimum port, and if we need more we could either switch to the full port or use the full port as inspiration to implement the newly needed parts

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mark9064
mark9064 approved these changes Oct 26, 2023
View reviewed changes

@mark9064 mark9064 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@NeroBurner
NeroBurner merged commit e6b96c2 into main Oct 26, 2023
@NeroBurner
NeroBurner deleted the lv_img_conv_py branch October 26, 2023 20:45
NeroBurner added a commit to InfiniTimeOrg/InfiniSim that referenced this pull request Oct 26, 2023
@NeroBurner
CI: install python3-pil for lv_img_conv.py
fad7eda
Install new build dependency introduced with move to minimum python
implementation of `lv_img_conv` node js script
InfiniTimeOrg/InfiniTime#1863
@NeroBurner NeroBurner mentioned this pull request Oct 26, 2023
CI: install python3-pil for lv_img_conv.py InfiniTimeOrg/InfiniSim#126
Merged
NeroBurner added a commit to InfiniTimeOrg/InfiniSim that referenced this pull request Oct 26, 2023
@NeroBurner
CI: install python3-pil for lv_img_conv.py
e6efcd5
Install new build dependency introduced with move to minimum python
implementation of `lv_img_conv` node js script
InfiniTimeOrg/InfiniTime#1863
NeroBurner added a commit to InfiniTimeOrg/InfiniSim that referenced this pull request Oct 26, 2023
@NeroBurner
CI: install python3-pil for lv_img_conv.py (#126)
fc8077a
Install new build dependency introduced with move to minimum python
implementation of `lv_img_conv` node js script
InfiniTimeOrg/InfiniTime#1863
This was referenced Oct 28, 2023
Build failing due to lv_img_conv InfiniTimeOrg/InfiniSim#120
Closed
Navigation external font breaks build with new @swc/core #1859
Closed
@NeroBurner NeroBurner mentioned this pull request Oct 28, 2023
Typescript not installed InfiniTimeOrg/InfiniSim#123
Closed
@JF002 JF002 added this to the 1.14.0 milestone Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JF002 JF002 JF002 approved these changes
@mark9064 mark9064 mark9064 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

maintenance Background work

Projects

None yet

Milestone

1.14.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@NeroBurner @JF002 @mark9064
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.