Converting Images to monochrome BMP's using the canvas
Recently i had to create monochrome bmp’s from a image to be able to print them on a thermal printer, i couldn’t find out how to do this online so i made a little code snippet with the help of chatgpt that does.
Thats it!
Fun fact BMP’s have the data order reversed thats why the rows = rows.reverse();
without that it still works but you just have a bmp with the data in the wrong order lol.
The canvas can create BMP’s and they work fine as BMP’s but they wont be 1 bit which this image will be.
I also have this tiny helper function that turns the canvas black white
I made a little demo down below if you just need to convert a single image and don’t need this in your website