Skip to main content

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

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pixelpuzzle-1.0.4.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pixelpuzzle-1.0.4-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file pixelpuzzle-1.0.4.tar.gz.

File metadata

  • Download URL: pixelpuzzle-1.0.4.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pixelpuzzle-1.0.4.tar.gz
Algorithm Hash digest
SHA256 e2f8efeefddf174fc90b7e3b42ab5dc008481e16ec15eabe358c524946e7c163
MD5 d0a8fbf4a08e830e8052ba0f9b9ccc39
BLAKE2b-256 e0d7784338de922de53e50b6c13b91c887b5f0a9c1fc13470d3b9f8c5685fd14

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixelpuzzle-1.0.4.tar.gz:

Publisher: python-publish.yml on ZhanZiyuan/PixelPuzzle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pixelpuzzle-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: pixelpuzzle-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pixelpuzzle-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a063cce6130513705e53288c73464755c6fe80bb6b64fe0b545ce4e8a3f075a2
MD5 799d77f260dcd21f1a0c250c7d42ce21
BLAKE2b-256 9a18b2acf3de1fde5fb37ec9de17476d669356c2a3ef75496d5b59eb30a7a8d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixelpuzzle-1.0.4-py3-none-any.whl:

Publisher: python-publish.yml on ZhanZiyuan/PixelPuzzle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page