Skip to main content

Create jigsaw puzzle pieces from an image

Project description

The Jigsaw Piece Maker

A jigsaw puzzle pieces generator that levels the playing field.

Currently in use by Puzzle Massive to create puzzles with 5000+ pieces.

It creates jigsaw puzzle pieces in multiple formats: svg, jpg, and png. The number and size of pieces are set by passing the script different options. It takes a while to run if doing a lot of pieces. Extra JSON files are created with details on size of pieces and adjacent pieces information which is commonly used when verifying that two pieces can join together.

Try out by running the piecemaker.sh script that will prompt for necessary options and run piecemaker inside a docker container. It will use the files in the examples directory by default.

# Build and run using docker
./piecemaker.sh

Installing

Requires:

Python Packages:

Other Software needed:

If on ubuntu or other debian based distro

apt-get --yes install libspatialindex6
apt-get --yes install optipng
apt-get --yes install python3-pil
apt-get --yes install potrace libffi-dev libxml2-dev python3-lxml python3-xcffib
apt-get --yes install librsvg2-bin
apt-get --yes install python3-pip

Install with pip in editable mode for developing and use virtualenv to isolate python dependencies

python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade --upgrade-strategy eager -e .

Usage

See the script.py for more. Not everything has been implemented. Use this example command to create 100 randomly generated jigsaw puzzle pieces from test.jpg image. This assumes that the 'test' directory is empty since that is where it will be placing all the generated files. The test.jpg is the source image that will be used when creating the pieces. It is not modified.

piecemaker --dir test  --number-of-pieces 100 test.jpg

Docker Usage

A Dockerfile also can be used to build an image and run it.

./update-dep.sh
DOCKER_BUILDKIT=1 docker build -t piecemaker:latest .

mkdir -p out/tmp
cp test.jpg out/
rm -rf out/tmp/*

docker run -it --rm \
    --mount type=bind,src=$(pwd)/out,dst=/out \
    piecemaker:latest \
    piecemaker --dir /out/tmp --number-of-pieces 100 /out/test.jpg

Contributing

Please contact me or create an issue.

Any submitted changes to this project require the commits to be signed off with the git command option '--signoff'. This ensures that the committer has the rights to submit the changes under the project's license and agrees to the Developer Certificate of Origin.

License

GNU Lesser General Public License v3.0

Maintenance

Where possible, an upkeep comment has been added to various parts of the source code. These are known areas that will require updates over time to reduce software rot. The upkeep comment follows this pattern to make it easier for commands like grep to find these comments.

Example UPKEEP comment has at least a 'due:' or 'label:' or 'interval:' value surrounded by double quotes (").

Example-> # UPKEEP due: "2022-12-14" label: "an example upkeep label" interval: "+4 months"

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

piecemaker-0.4.7.tar.gz (43.2 kB view details)

Uploaded Source

Built Distribution

piecemaker-0.4.7-py3-none-any.whl (56.6 kB view details)

Uploaded Python 3

File details

Details for the file piecemaker-0.4.7.tar.gz.

File metadata

  • Download URL: piecemaker-0.4.7.tar.gz
  • Upload date:
  • Size: 43.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for piecemaker-0.4.7.tar.gz
Algorithm Hash digest
SHA256 ac918dd4d2632be963292d67b0b146cdc868c04fa2da8450e316443f43a894c8
MD5 11384b59ff3f6200927f9a0de2a549ff
BLAKE2b-256 4d1bbeb80db1dc6c377b6565000473220897f1dafaae8fb6ee4e11ea43f665f3

See more details on using hashes here.

File details

Details for the file piecemaker-0.4.7-py3-none-any.whl.

File metadata

  • Download URL: piecemaker-0.4.7-py3-none-any.whl
  • Upload date:
  • Size: 56.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for piecemaker-0.4.7-py3-none-any.whl
Algorithm Hash digest
SHA256 507675dc58782aa227011dc55dc3b49da980019a6c25467824b51f5af3ff891d
MD5 319acc25898370243c96ed122ad4397d
BLAKE2b-256 6a8b0ab830c97c8d8e6937a1e3230b155d506a381ce86a1ed02ef2494d29befd

See more details on using hashes here.

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