pythonpython-2.7python-3.ximage-processingpiet

Encode strings to image using Python


Is there any library in Python that encodes data to bitmap patterns and decodes images to data, like the Piet language?

Hello World with Piet

Hello World with Piet

UPDATE

I want to get a string, like Hello, world or an URL and encode it as an image, then read this image and decode to a string. Something like a QR code, but using bitmap.


Solution

  • Depending on you plan for image manipulation or image processing , Python Image Library PIL may be what you are looking for.

    Below is a demo code that applies inbuilt filters, derived from here There are numerous other image processing and pixel manipulation tools available within PIL

    Demo Code

    from PIL import Image
    from PIL import ImageFilter
    
    i = Image.open("gImage1.jpg")
    im2 = i.filter(ImageFilter.EMBOSS)
    im3 = i.filter(ImageFilter.FIND_EDGES)
    
    im2.save("gImage1_EMBOSS.jpg")
    im3.save("gImage1_FIND_EDGES.jpg")
    

    Input Image

    Input Image

    Output Images
    EMBOSS Filter

    FIND EDGES FILTER