Split an image into n-pieces and shuffle them.
You can simply:
pip install image-shuffler
Or you can also:
- Clone the repository to your local machine.
- Enter the directory.
- Download necessary modules/libraries.
git clone https://github.com/gabrielstork/image-shuffler.git
cd image-shuffler
pip install -r requirements.txt
First, you need to import the Shuffler
class.
from image_shuffler import Shuffler
Then, instantiate it passing a valid path of an image as its argument.
image = Shuffler('lenna.png')
Now, to actually shuffle, you need to use the shuffle()
method. The matrix
parameter defines the number of pieces that will be in x
and y
, in this case, there will be a total of 16 pieces (you can see it in the image on the top of this file).
image.shuffle(matrix=(4, 4))
To take a look at the shuffled image, you can use the show()
method (a new window will pop up).
image.show()
No arguments are needed to save the image. It will be saved in the same directory as the oringinal one and, in this case, with shuffled_lena.png
as its name.
image.save()