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

Advice needed XBM conversion #5

Open
pastukhov opened this issue Dec 3, 2015 · 3 comments
Open

Advice needed XBM conversion #5

pastukhov opened this issue Dec 3, 2015 · 3 comments

Comments

@pastukhov
Copy link

Can you say how to convert images to MONO?

@squix78
Copy link
Owner

squix78 commented Dec 3, 2015

Hi Artem

I described it here:
http://blog.squix.ch/2015/05/esp8266-nodemcu-how-to-create-xbm.html

Hope that helps
Daniel

2015-12-03 11:56 GMT+01:00 Artem Pastukhov [email protected]:

Can you say how to convert images to MONO?


Reply to this email directly or view it on GitHub
#5.

@pastukhov
Copy link
Author

Hi!
I have made some black magic:

#!/bin/bash

for icon in *png; do
    convert $icon -depth 1 ./out/$(basename $icon .png)_1bpp.png
    convert ./out/$(basename $icon .png)_1bpp.png -background white -alpha Background ./out/$(basename $icon .png)_1bpp.xbm
    cat ./out/$(basename $icon .png)_1bpp.xbm | xxd -r -p |dd skip=6 bs=1  > ./out/$(basename $icon .png).xbm.mono
done

rm out/*png out/*xbm

@pastukhov
Copy link
Author

Black magic v2.0

#!/bin/bash

for icon in *png; do
    convert $icon -depth 1 ./out/$(basename $icon .png)_1bpp.png
    convert ./out/$(basename $icon .png)_1bpp.png -background white -alpha Background ./out/$(basename $icon .png)_1bpp.xbm
    cat ./out/$(basename $icon .png)_1bpp.xbm | tr '\n' ' '  | tr -d " " |sed  -e s'#^.*{##g'  | sed s'#,}##' |sed s'/;//' | xxd -r -p > ./out/$(basename $icon .png).xbm.mono
done

rm out/*png out/*xbm

For all the png files in current folder it convert to 1 bit per pixel first, then set background to white and save to xbm. After filter out all except hex array, convert to binary and write to resulting mono image

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

No branches or pull requests

2 participants