Reputation: 41
I want to plot a string of monochrome bmp (something like 0x424D36020000000000003E0000.......
) in Python, and further convert the plot to JPG or some common type of image.
Does anyone know how to do so?
Thanks
Upvotes: 1
Views: 1242
Reputation: 207560
You can do it like this with PIL/Pillow:
from PIL import Image
from io import BytesIO
# Get your string called "bmp" wherever/however you got it
# Open string as PIL image
im = Image.open(BytesIO(bmp))
Yo can now display the image with:
im.show()
You can get the size of the image with:
print(im.size)
And you can save it as a JPEG or anything else you fancy like this:
im.save('result.jpg')
Upvotes: 1