{"id":29020228,"url":"https://github.com/genietim/lego-mosaic-maker","last_synced_at":"2025-06-26T01:04:51.426Z","repository":{"id":298080497,"uuid":"998783854","full_name":"GenieTim/lego-mosaic-maker","owner":"GenieTim","description":"Convert an image to a 2D Lego mosaic","archived":false,"fork":false,"pushed_at":"2025-06-09T09:54:50.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-18T08:55:23.071Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GenieTim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-09T08:42:32.000Z","updated_at":"2025-06-09T09:54:53.000Z","dependencies_parsed_at":"2025-06-09T10:30:04.721Z","dependency_job_id":null,"html_url":"https://github.com/GenieTim/lego-mosaic-maker","commit_stats":null,"previous_names":["genietim/lego-mosaic-maker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/GenieTim/lego-mosaic-maker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenieTim%2Flego-mosaic-maker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenieTim%2Flego-mosaic-maker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenieTim%2Flego-mosaic-maker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenieTim%2Flego-mosaic-maker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GenieTim","download_url":"https://codeload.github.com/GenieTim/lego-mosaic-maker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenieTim%2Flego-mosaic-maker/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261978911,"owners_count":23239417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-26T01:04:48.703Z","updated_at":"2025-06-26T01:04:51.411Z","avatar_url":"https://github.com/GenieTim.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🧱 LEGO Mosaic Maker\n\nConvert any image into a beautiful LEGO mosaic with realistic color matching and detailed building instructions!\n\n- [🧱 LEGO Mosaic Maker](#-lego-mosaic-maker)\n  - [✨ Features](#-features)\n  - [🚀 Quick Start](#-quick-start)\n    - [Prerequisites](#prerequisites)\n    - [Installation](#installation)\n    - [Basic Usage](#basic-usage)\n  - [📖 Detailed Usage](#-detailed-usage)\n    - [Command Line Options](#command-line-options)\n    - [Examples](#examples)\n  - [📁 Output Files](#-output-files)\n    - [Sample Color Report](#sample-color-report)\n  - [🔧 Advanced Configuration](#-advanced-configuration)\n    - [Updating LEGO Parts Database](#updating-lego-parts-database)\n    - [Color Selection Criteria](#color-selection-criteria)\n    - [Performance Optimization](#performance-optimization)\n  - [🎨 Tips for Best Results](#-tips-for-best-results)\n    - [Image Selection](#image-selection)\n    - [Size Recommendations](#size-recommendations)\n    - [Building Tips](#building-tips)\n  - [🛠️ Technical Details](#️-technical-details)\n    - [Dependencies](#dependencies)\n    - [Algorithm Overview](#algorithm-overview)\n    - [Color Accuracy](#color-accuracy)\n  - [⚠️ Disclaimer](#️-disclaimer)\n  - [📄 License](#-license)\n  - [🤝 Contributing](#-contributing)\n    - [Pull Request Process](#pull-request-process)\n    - [Automatic Code Formatting](#automatic-code-formatting)\n  - [📞 Support](#-support)\n  - [🙏 Acknowledgments](#-acknowledgments)\n\n## ✨ Features\n\n- **Precise Color Matching**: Uses CIEDE2000 color difference formula for accurate color conversion\n- **Realistic LEGO Colors**: Only uses colors from parts that are:\n  - Released in the last 10 years\n  - Currently available (not retired/discontinued)\n  - 1x1 flat tiles or plates\n- **Multiple Output Formats**:\n  - Small mosaic (actual LEGO dimensions)\n  - Large mosaic (scaled to original image size)\n  - Detailed color usage report with part counts\n- **Optimized Performance**: Multi-core processing for fast conversion\n- **Flexible Sizing**: Specify either width or height in LEGO pieces\n\n## 🚀 Quick Start\n\n### Prerequisites\n\n- Python 3.7+\n- Required packages (install via `pip install -r requirements.txt`)\n\n### Installation\n\n1. Clone this repository:\n\n```bash\ngit clone git@github.com:GenieTim/lego-mosaic-maker.git\ncd lego-mosaic-maker\n```\n\n2. Install dependencies:\n\n```bash\npip install -r requirements.txt\n```\n\n3. Download LEGO parts database:\n\n```bash\npython update_lego_parts_data.py\n```\n\n### Basic Usage\n\n```bash\n# Create a 48-piece wide mosaic\npython foto_to_lego_mosaic.py your_image.jpg --width 48\n\n# Create a 32-piece tall mosaic\npython foto_to_lego_mosaic.py your_image.png --height 32\n```\n\n## 📖 Detailed Usage\n\n### Command Line Options\n\n```\nusage: foto_to_lego_mosaic.py [-h] (--width WIDTH | --height HEIGHT) [--output OUTPUT] image\n\npositional arguments:\n  image                 Path to the input image\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --width WIDTH, -w WIDTH\n                        Width of the mosaic in LEGO pieces\n  --height HEIGHT       Height of the mosaic in LEGO pieces\n  --output OUTPUT, -o OUTPUT\n                        Output directory (default: output)\n```\n\n### Examples\n\n```bash\n# Basic usage with width specification\npython foto_to_lego_mosaic.py photo.jpg --width 48\n\n# Specify height instead of width\npython foto_to_lego_mosaic.py landscape.png --height 32\n\n# Custom output directory\npython foto_to_lego_mosaic.py portrait.jpg --width 64 --output my_mosaics\n```\n\n## 📁 Output Files\n\nFor each processed image, the tool generates:\n\n1. **`[filename]_mosaic_[width]x[height]_[timestamp].png`**\n\n   - Small mosaic at actual LEGO piece resolution\n   - Perfect for viewing pixel-by-pixel instructions\n\n2. **`[filename]_mosaic_large_[width]x[height]_[timestamp].png`**\n\n   - Large mosaic scaled to original image dimensions\n   - Better for viewing on devices without zoom capability\n\n3. **`[filename]_color_report_[timestamp].txt`**\n   - Detailed breakdown of required LEGO pieces\n   - Lists each color with exact piece counts\n   - Perfect for shopping list creation\n\n### Sample Color Report\n\n```\nLEGO Mosaic Color Usage Report\nImage: /path/to/your/photo.jpg\nMosaic size: 96x130 pieces\nTotal pieces: 12480\nUnique colors: 8\n\nWhite (#FFFFFF): 3207 pieces\nGlow in Dark White (#D9D9D9): 2782 pieces\nLight Bluish Gray (#A0A5A9): 1835 pieces\nPearl Titanium (#3E3C39): 1457 pieces\nBlack (#05131D): 921 pieces\nDark Bluish Gray (#6C6E68): 913 pieces\nFlat Silver (#898788): 743 pieces\nLight Aqua (#ADC3C0): 622 pieces\n```\n\n## 🔧 Advanced Configuration\n\n### Updating LEGO Parts Database\n\nThe tool uses data from [Rebrickable](https://rebrickable.com/downloads/) to ensure accurate color information. Update the database periodically:\n\n```bash\npython update_lego_parts_data.py\n```\n\nThis script:\n\n1. Downloads the latest LEGO parts data from Rebrickable\n2. Extracts and processes the CSV files\n3. Stores them in the `data/` directory\n\n### Color Selection Criteria\n\nThe tool filters LEGO colors based on:\n\n- **Availability**: Only colors used in 1x1 tiles or plates\n- **Recency**: Parts released in the last 10 years\n- **Status**: Currently available (not discontinued)\n- **Transparency**: Excludes transparent pieces\n\n### Performance Optimization\n\n- **Multi-core Processing**: Automatically uses all available CPU cores\n- **Color Quantization**: Reduces similar colors to speed up processing\n- **Caching**: Reuses color calculations for identical pixels\n\n## 🎨 Tips for Best Results\n\n### Image Selection\n\n- **High Contrast**: Images with clear contrasts work best\n- **Simple Subjects**: Portraits, logos, and simple scenes are ideal\n- **Avoid Gradients**: Sharp color transitions look better than smooth gradients\n\n### Size Recommendations\n\n- **Small Mosaics (16-32 pieces)**: Good for simple images, logos\n- **Medium Mosaics (48-64 pieces)**: Best balance of detail and buildability\n- **Large Mosaics (96+ pieces)**: For complex images, requires many pieces\n\n### Building Tips\n\n- Use the small mosaic image for pixel-perfect reference\n- Build row by row for easier assembly\n- Consider framing options for display\n\n## 🛠️ Technical Details\n\n### Dependencies\n\n- **Pillow (PIL)**: Image processing and manipulation\n- **NumPy**: Efficient array operations\n- **Pandas**: Data processing and filtering\n- **colorspacious**: CIEDE2000 color difference calculations\n- **requests**: Downloading LEGO parts data\n- **beautifulsoup4**: Web scraping for data updates\n\n### Algorithm Overview\n\n1. **Image Preprocessing**: Resize and quantize colors\n2. **Color Analysis**: Extract unique colors from quantized image\n3. **LEGO Matching**: Find closest LEGO colors using CIEDE2000\n4. **Mosaic Generation**: Apply color mapping to create final mosaic\n5. **Output Creation**: Generate images and usage reports\n\n### Color Accuracy\n\nUses the CIEDE2000 color difference formula, which closely matches human color perception, ensuring the most visually accurate color matching possible.\n\n## ⚠️ Disclaimer\n\nThis project is **not affiliated with, endorsed by, or sponsored by The LEGO Group**.\n\n- LEGO® is a trademark of The LEGO Group\n- This is an unofficial, fan-created tool for educational and personal use\n- The LEGO Group does not sponsor, authorize, or endorse this project\n- All trademarks and copyrights belong to their respective owners\n- This tool is provided \"as is\" without warranty of any kind\n\nFor official LEGO products and services, please visit [lego.com](https://www.lego.com).\n\n## 📄 License\n\nThis project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.\n\n## 🤝 Contributing\n\nContributions are welcome! Please follow these guidelines:\n\n1. **Code Style**: All code must pass PEP8 compliance checks\n2. **Formatting**: Use `black` and `isort` for code formatting\n3. **Testing**: Ensure your changes don't break existing functionality\n4. **Documentation**: Update README if adding new features\n\n### Pull Request Process\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Make your changes following code quality standards\n4. Run quality checks locally: `black . \u0026\u0026 isort . \u0026\u0026 flake8 .`\n5. Commit your changes (`git commit -m 'Add amazing feature'`)\n6. Push to the branch (`git push origin feature/amazing-feature`)\n7. Open a Pull Request\n\n### Automatic Code Formatting\n\nIf your PR doesn't pass formatting checks, collaborators can comment `/format` on the PR to automatically format the code.\n\n## 📞 Support\n\nIf you encounter any issues or have questions:\n\n1. Check the [Issues](https://github.com/GenieTim/lego-mosaic-maker/issues) page\n2. Create a new issue with detailed information about your problem\n3. Include your Python version, operating system, and example command\n\n## 🙏 Acknowledgments\n\n- [Rebrickable](https://rebrickable.com/) for providing comprehensive LEGO parts database\n- The LEGO Group for creating the amazing building system that inspired this project\n- The open-source community for the excellent libraries that make this tool possible\n\n---\n\n_Happy building! 🧱_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenietim%2Flego-mosaic-maker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenietim%2Flego-mosaic-maker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenietim%2Flego-mosaic-maker/lists"}