Puzzlify transforms any image into an interactive swap-tile puzzle. Load your favorite photo, scramble the pieces, and race against the clock to restore the original image. Perfect for brain training or just relaxing with a visual challenge.
| Category | Description |
|---|---|
| ๐ธ Image Loading | Load any common image format (JPG, PNG, BMP, GIF, WebP, TIFF) |
| ๐งฉ Flexible Grids | Choose from 9 piece counts: 4, 6, 8, 9, 12, 16, 20, 25, or 32 pieces |
| ๐ฎ Intuitive Controls | Click a tile to select โ click another to swap |
| โฑ๏ธ Stats Tracking | Real-time timer and move counter during gameplay |
| ๐จ Visual Feedback | Orange highlight for selected tiles, green outline for correct placements |
| ๐ Game Controls | Shuffle & Start, Reset, and Solve (instant completion) |
| ๐ผ๏ธ Thumbnail Preview | See your loaded image in the left panel |
| ๐ป Lightweight | Pure Python with Tkinter + Pillow โ no heavy dependencies |
- Python 3.8 or higher
- Pillow library for image processing
# Clone the repository
git clone https://github.com/yourusername/puzzlify.git
cd puzzlify
# Install dependencies
pip install Pillow
# Run the game
python puzzle_tool.pyNote: Tkinter is included with Python on Windows and macOS.
On Linux, install it with:sudo apt-get install python3-tk
-
Load an Image
Click[ LOAD IMAGE ]and select any photo from your computer. -
Choose Difficulty
Select the number of puzzle pieces (more pieces = harder puzzle). -
Shuffle & Start
Click[ SHUFFLE & START ]to scramble the tiles and begin the timer. -
Swap Tiles
- Click a tile to select it (orange border appears)
- Click another tile to swap positions
- Continue until the image is fully restored
-
Win!
When all tiles are in place, a victory overlay appears with your final stats.
| Button | Function |
|---|---|
| RESET | Restores the puzzle to the solved state (keeps current image) |
| SOLVE | Instantly completes the puzzle (useful for seeing the final image) |
Original Image โ Crop to Aspect Ratio โ Resize to Board (520ร520)
โ Calculate Optimal Grid (cols ร rows) โ Slice into Pieces
โ Store in Memory โ Display on Canvas
The tool automatically determines the optimal grid layout to be as square as possible while exactly matching the chosen piece count:
def get_grid(n):
"""Returns (cols, rows) for n pieces โ closest to square, wider than tall."""
best = (n, 1)
best_diff = n - 1
for c in range(2, n + 1):
if n % c == 0:
r = n // c
diff = abs(c - r)
if diff < best_diff or (diff == best_diff and c >= r):
best_diff = diff
best = (c, r)
cols, rows = best
if cols < rows:
cols, rows = rows, cols
return cols, rows- Swap Algorithm: Two tiles exchange positions in the order list; each swap increments the move counter
- Win Detection: Puzzle is solved when
order == [0, 1, 2, ..., n-1] - Timer: Real-time tracking that stops automatically on solution
- Left Panel: Controls, image preview, stats, and instructions
- Right Panel: Interactive canvas displaying the puzzle grid
- Theme: Custom dark color scheme with accent colors for better visibility
- Responsive: Automatically adjusts piece dimensions based on grid size
puzzlify/
โโโ puzzle_tool.py # Main application (800+ lines of code)
โโโ demo1.png # Start screen screenshot
โโโ demo2.png # Loaded image screenshot
โโโ demo3.png # Active gameplay screenshot
โโโ README.md # This file
โโโ LICENSE # MIT License
- Python 3.8+ โ Core programming language
- Tkinter โ GUI framework (built-in)
- Pillow (PIL) โ Image processing library
- Save/Load State โ Resume puzzles later
- Difficulty Modes โ Limited moves, timed challenges
- Animations โ Smooth tile swaps and transitions
- Sound Effects โ Feedback sounds for swaps and solves
- Leaderboard โ Track best times locally
- Custom Themes โ Multiple color schemes
- Keyboard Shortcuts โ Faster navigation
Contributions are welcome! Whether it's:
- ๐ Bug reports
- ๐ก Feature suggestions
- ๐ Documentation improvements
- ๐ง Pull requests
Please open an issue first to discuss what you'd like to change.
This project is licensed under the MIT License โ see the LICENSE file for details.
KAZIM KHAN
- Portfolio: kazimportfolio
- GitHub: kazim-45
- Project Link: github.com/kazim-45/puzzlify
- Inspired by classic sliding puzzles and modern brain training apps
- Built with Python's excellent Tkinter and Pillow libraries
- Special thanks to the open-source community
If you found this project useful, please give it a star โญ on GitHub!
It helps others discover the project and motivates further development.
Made with ๐งฉ and โ