Skip to main content

Split image into tiles and scramble/unscramble it with seed.

Project description

Pycasso

Image obfuscation tool with seed.

Example

Scramble

Using scramble mode on export on this sample image will produce the following output:

example_scramble

Unscramble

To revert the image to its original state, use the same seed and slice_size on unscramble mode:

img = 'examples/en_Pepper-and-Carrot_by-David-Revoy_E05P01_p2_pycasso.png'
slice_size = (30, 30)
seed = 'Pycasso'

example_unscramble

Credits

Getting Started

Prerequisites

  • Python 3.8+

Setup

Install from PyPI

$ pip install image-scramble

Install from source

  • First, you should get a copy of this project in your local machine by either downloading the zip file or cloning the repository. git clone https://github.com/catsital/pycasso.git
  • cd into pycasso directory.
  • Run python setup.py install to install package.

Usage

Using the command-line utility

After installing, you can get started by using the command-line utility to scramble or unscramble an image by:

$ pycasso image_input.png scramble

This will produce a scrambled image with seed based on your current system time. Hence, the output will be completely unpredictable and irreversible. Use the options -n for slice_width and slice_height and -s for seed to fine-tune your desired output, like so:

$ pycasso image_input.png scramble -n 50 30 -s seed -o image_output.png

Using in a script

Initialize a Canvas and use scramble on export by:

from pycasso import Canvas
img = 'image_input.png'
slice_size = (50, 30)
seed = 'seed'
pycasso = Canvas(img, slice_size, seed)
pycasso.export(mode='scramble', path='image_output', format='png')

This can be also achieved in a one-liner:

Canvas('image_input.png', (50, 30), 'seed').export('scramble', 'image_output', 'png')

Params

img

  • Path to image source

slice_size

  • Size (width and height) of each slice

seed

  • Seed to shuffle in same sequence

output

  • Output file name

format

  • Image format

Modes

scramble default

  • Splits and scrambles image into tiles

unscramble

  • Reverts the image to its original form given the same seed

Modes can be used interchangeably and conversely perform their original functions. (i.e. If you use unscramble to scramble an image, it will scramble the image. Consequently you should use scramble to unscramble the image to its original form.)

License

Copyright (c) 2021 Julia Torres
Copyright (c) 2015 Andre Caetano

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

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

image-scramble-2.0.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

image_scramble-2.0.0-py2.py3-none-any.whl (9.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file image-scramble-2.0.0.tar.gz.

File metadata

  • Download URL: image-scramble-2.0.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for image-scramble-2.0.0.tar.gz
Algorithm Hash digest
SHA256 7f18ce3121b063ac919e35b907a7d3fbac9dc81fa5562c4359e19641740ff39f
MD5 5c2c9e615d3321c02c995ce6dbbd5b9d
BLAKE2b-256 9c7f078260bf0bc3563b433025c143800e3d6d7cdd23a3ba7c78958bee5502a1

See more details on using hashes here.

Provenance

File details

Details for the file image_scramble-2.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: image_scramble-2.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for image_scramble-2.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f8bbeca96ae9aefd5f48e7073f4c3c05b223a7d0afb512eb82d19424d2c6ef6f
MD5 8bf4f7a3ba7b35285f64ee6d5b8ea30f
BLAKE2b-256 8ee2dfc494cbf1c1886541726de89a2fa7e12841f1808e20852b41b7a8022886

See more details on using hashes here.

Provenance

Supported by

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