Skip to content

ZhanZiyuan/PixelPuzzle

Repository files navigation

logo

PixelPuzzle

GitHub Actions Workflow Status GitHub last commit PyPI - Python Version PyPI - Version PyPI - Wheel PyPI - Downloads GitHub License

Encode/decode images using Base64 or shuffle/recover the pixels of images.

Motivations

This repository is a renewed implementation of Python code I saw a long time ago on CoolApk:

import matplotlib.pyplot as plt
import numpy as np
from PIL import Image

# Get the three-dimensional pixel channel matrix of the image
img = np.array(Image.open("C:/Users/user/Downloads/test.png"))
# First dimension
row_len = img.shape[0]

# Shuffle the dimension indices
row_index = np.random.permutation(row_len)
# Generate the chaotic image
img_chaos = img[row_index, :, :]

# Use sorting to unshuffle the image
img_sort = img[np.sort(row_index), :, :]

# Plot the chaotic and unshuffled images
plt.figure("Chaotic and Unshuffled Images")
plt.subplot(121)
plt.imshow(img_chaos)
plt.subplot(122)
plt.imshow(img_sort)
plt.show()

And it can also be seen as an implementation of similar functions of the Android application 图片混淆 in Python.

Installation

PixelPuzzle can be installed from PyPI:

pip install pixelpuzzle

or download the repository and run:

pip install .

as of the repository root folder.

Examples

  • The original image:

    The original image

  • The shuffled image (using the random seed 0721):

    The shuffled image

  • The recovered image:

    The recovered image

Packaging

The binaries are created with Nuitka PyInstaller:

# Package it on Linux
pyinstaller --name PixelPuzzle --onefile -p pixelpuzzle pixelpuzzle/__main__.py

# Package it on Windows
pyinstaller --name PixelPuzzle --onefile --icon python.ico -p pixelpuzzle pixelpuzzle/__main__.py

Web Applications

Deploy Pixel Puzzle on Vercel.

Similar Projects

Here are some links to other similar projects that I am aware of:

Copyrights

PixelPuzzle is a free, open-source software package (distributed under the GPLv3 license). The sample image used is downloaded from satchely doki doki literature club! natsuki. The Python icon is downloaded from python.ico.

Packages

No packages published

Languages