i3lock: Providing an invalid PNG gives confusing error message "out of memory"
I saw in another issue the rationale for no JPG support or what have you, but it seems a little cryptic to give an out of memory error message when the the file is not a valid PNG.
How to reproduce
➜ ~ wget -q https://upload.wikimedia.org/wikipedia/commons/d/d6/Bromo-Tengger-Semeru_banner_2.jpg
➜ ~ i3lock -i Bromo-Tengger-Semeru_banner_2.jpg
Could not load image "Bromo-Tengger-Semeru_banner_2.jpg": out of memory
➜ ~ i3lock -i /dev/zero
Could not load image "/dev/zero": out of memory
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (13 by maintainers)
Allow me to insist since the discussion continues: reading the first 8 bytes of the file doesn’t really mean “parsing” but rather like a CRC check. I understand you don’t like it, but it’s 100% effective, easy to implement and would virtually never change…
I agree that the validation should happen in cairo. For the time being, I’d be okay with a PR which examines the first 8 bytes, though.
If you’re not prepared to actually do any parsing of the image , why not just add some warning text to the error itself explaining that “only png is supported and cairo error messages are sometimes inaccurate” or words to that affect?
That’s what https://github.com/i3/i3lock/issues/114#issuecomment-356929698 already suggested.