-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Verification
- I searched for similar issues (including closed issues) and found none was relevant.
Introduce the issue
Pillow supports a lot of different modes as seen here
'P' mode is an 8-bit pixel mode that not only is space efficient but also supports color and transparency. When trying save an an external resource using CF_TRUE_COLOR_ALPHA, the error TypeError: 'int' object is not subscriptable is printed because this mode does not have "channels".
Steps to reproduce:
- Follow the official docs for external resources.
- Use the following image to generate an lv compatible file:

- See error is reproduced.
A workaround for now is to use Pillow to convert the mode from 'P' to 'RGBA', but this increases the file size.
Full traceback:
Beginning conversion of /home/user/Documents/projects/pinetime/InfiniTime/src/resources/images/FEPT/Enemy.png
overwriting Enemy.bin
Traceback (most recent call last):
File "/home/user/Documents/projects/pinetime/InfiniTime/src/resources/lv_img_conv.py", line 193, in <module>
sys.exit(main())
^^^^^^
File "/home/user/Documents/projects/pinetime/InfiniTime/src/resources/lv_img_conv.py", line 122, in main
r_act = classify_pixel(pixel[0], 5)
~~~~~^^^
TypeError: 'int' object is not subscriptable
Traceback (most recent call last):
File "/home/user/Documents/projects/pinetime/InfiniTime/src/resources/generate-img.py", line 59, in <module>
main()
File "/home/user/Documents/projects/pinetime/InfiniTime/src/resources/generate-img.py", line 54, in main
subprocess.check_call(line)
File "/usr/lib64/python3.11/subprocess.py", line 413, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python3.11', '/home/user/Documents/projects/pinetime/InfiniTime/src/resources/lv_img_conv.py', '/home/user/Documents/projects/pinetime/InfiniTime/src/resources/images/FEPT/Enemy.png', '--force', '--output-file', 'Enemy.bin', '--color-format', 'CF_TRUE_COLOR_ALPHA', '--output-format', 'bin', '--binary-format', 'ARGB8565_RBSWAP']' returned non-zero exit status 1.
Preferred solution
Add a condition to check the mode before doing the conversion and handle accordingly
Version
No response