https://github.com/zhanziyuan/pixelpuzzle
Shuffle/recover the pixels of images.
https://github.com/zhanziyuan/pixelpuzzle
anime encryption image image-processing numpy python
Last synced: about 1 month ago
JSON representation
Shuffle/recover the pixels of images.
- Host: GitHub
- URL: https://github.com/zhanziyuan/pixelpuzzle
- Owner: ZhanZiyuan
- License: gpl-3.0
- Created: 2024-05-17T14:03:29.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-08-23T02:40:40.000Z (10 months ago)
- Last Synced: 2025-10-26T18:54:22.383Z (8 months ago)
- Topics: anime, encryption, image, image-processing, numpy, python
- Language: Python
- Homepage: https://pypi.org/project/pixelpuzzle/
- Size: 32.8 MB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PixelPuzzle
[](https://github.com/ZhanZiyuan/PixelPuzzle/blob/main/.github/workflows/python-publish.yml)
[](https://github.com/ZhanZiyuan/PixelPuzzle/commits/main/)
[](https://pypi.org/project/pixelpuzzle/)
[](https://pypi.org/project/pixelpuzzle/)
[](https://pypi.org/project/pixelpuzzle/#files)
[](https://pypistats.org/packages/pixelpuzzle)
[](https://github.com/ZhanZiyuan/PixelPuzzle/blob/main/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](https://www.coolapk.com/):
```python
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
[图片混淆](https://www.coolapk.com/feed/27933328?shareKey=N2QxMWY3MTExMDc0NjY0OWQwYWE)
in Python.
## Installation
PixelPuzzle can be installed
from [PyPI](https://pypi.org/project/pixelpuzzle/):
```bash
pip install pixelpuzzle
```
or download the repository and run:
```bash
pip install .
```
as of the repository root folder.
## Examples
- The original image:

- The shuffled image (using the random seed `0721`):

- The recovered image:

## Packaging
The binaries are created with
~~[Nuitka](https://github.com/Nuitka/Nuitka)~~
[PyInstaller](https://github.com/pyinstaller/pyinstaller):
```bash
# 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](https://pixelpuzzle-web.vercel.app/)
on [Vercel](https://github.com/vercel/vercel).
## Similar Projects
Here are some links to other similar projects that I am aware of:
- [PicEncryptApp](https://github.com/goldsudo/PicEncryptApp)
- [piConfuse](https://github.com/Conyrol/piConfuse)
- [Jencryption](https://github.com/Jinnrry/Jencryption)
- [RicEncrypt](https://github.com/NaviHX/ricencrypt)
## Copyrights
PixelPuzzle is a free, open-source software package
(distributed under the [GPLv3 license](./LICENSE)).
The sample image used is downloaded from
[satchely doki doki literature club! natsuki](https://yande.re/post/show/465068).
The Python icon is downloaded from
[python.ico](https://github.com/python/cpython/blob/main/PC/icons/python.ico).