Codify your text files or Python strings.
You can simply:
pip install pytextcodifier
Or you can also:
- Clone the repository to your local machine.
- Enter the directory.
- Download necessary modules/libraries.
git clone https://github.com/gabrielstork/pytextcodifier.git
cd pytextcodifier
pip install -r requirements.txt
pytextcodifier allows you transform Python strings or text files (check example.txt
and see the text file used to generate the image below) into encoded images like this:
Every image matrix has two 8 digit arrays called stop and identifier (to be precise, the first 16 pixel values in the flattened image matrix). The identifier tells how the code should read the image, showing where the correct characters are located in the matrix. A private image requires a key to correctly extract the text in it, on the other side, if it is a non-private image, the text is extracted directly.
Importing Encoder
class.
from pytextcodifier import Encoder
Using the content of example.txt
.
text = Encoder('example.txt', is_file=True)
Using encode()
method with default arguments to actually encode it.
text.encode(size=(250, 250), private=False)
Seeing the generated encoded image (a new window will pop up).
text.show()
Saving it.
text.save('images/public_example.png')
Importing Decoder
class.
from pytextcodifier import Decoder
Instantiating the class passing an image as argument.
image = Decoder('example.png')
Decoding the image.
image.decode()
Seeing the text.
image.show()
Saving the text.
image.save('example.txt')
Importing Encoder
class.
from pytextcodifier import Encoder
Using the content of example.txt
.
text = Encoder('example.txt', is_file=True)
Using encode()
method setting the private
parameter to True
.
text.encode(size=(250, 250), private=True)
Saving it. This will save an extra image named 'key_private_example.png', you must use this to get the text correctly when decoding it.
text.save('images/private_example.png')
Importing Decoder
class.
from pytextcodifier import Decoder
Instantiating the class passing an image as argument.
image = Decoder('example.png')
Decoding the image.
image.decode(key='key_private_example.png')
Seeing the text.
image.show()
Saving the text.
image.save('example.txt')