Name | brickmos JSON |
Version |
0.1.1
JSON |
| download |
home_page | None |
Summary | brickmos is a humble Lego mosaic generator. |
upload_time | 2024-09-02 15:40:48 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | MIT License Copyright (c) 2020 Marius Merschformann 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. |
keywords |
bricklink
lego
mosaic
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# brickmos
**brick**-**mos**aic
[![pypi_version](https://img.shields.io/pypi/v/brickmos?label=pypi)](https://pypi.org/project/brickmos)[![build](https://github.com/merschformann/brickmos/actions/workflows/build.yml/badge.svg)](https://github.com/merschformann/brickmos/actions/workflows/build.yml)
This is a simple tool for converting images to Lego mosaics such that their
parts can be ordered quite easily from bricklink (https://www.bricklink.com/).
I wrote this for myself for a birthday present I worked on, but wanted to leave
it here for others to re-use or as inspiration.
![process-steps](https://raw.githubusercontent.com/merschformann/brickmos/main/material/process-steps.svg)
(ltr: original image, pixelated image with original color, image with colors
mapped to given Lego colors; [image source](https://www.vincenthie.com/gallery/disney/ironmanportrait))
## Motivation & alternatives
This is a rather simple script which worked well for me, as I went back and
forth between my image editing tool and modifying the color pallet. I really
like this continuous process of shaping the result while keeping colors/brick
types and their prices under control. I even ended up replacing one 1x1 plate
with a 1x1 tile, since the respective color was too expensive on bricklink.
Furthermore, I was only interested in full 1x1 mosaics, similar to the Lego
mosaic art product line. I also ended up buying the frame parts used for the
Lego art frame, as it is extendable and easily wall-mountable (see [here](https://www.lego.com/de-de/campaigns/art/)).
However, if you are more interested in a GUI application, different workflow or
automatically chosen larger than 1x1 pixels, you may want to have a look at the
following alternatives (if I forgot an alternative here, let me know):
- Bricklink studio (full-blown brick set designer with a mosaic feature, (see
[here](https://www.bricklink.com/v3/studio/download.page))
- PicToBrick (specifically made for brick mosaics, see [here](http://www.pictobrick.de/en/pictobrick.shtml))
## Quickstart
The following should get you started.
### Dependencies
Main dependencies are:
- Python (I used python 3.8)
- `opencv-python` (the version I used is defined in _requirements.txt_)
If you run into problems missing `libGL.so`, install the following:
```bash
sudo apt update
sudo apt install libgl1-mesa-glx
```
### Installation
Install via PyPi
```bash
pip install brickmos --upgrade
```
### Process an image
Convert an image by invoking the script as follows:
`brickmos --image_file data/iron-man-portrait.jpg --output_directory="temp"`
Or alternatively clone this repo and run it directly:
`python run.py --image_file data/iron-man-portrait.jpg --output_directory="temp"`
Repeat the process while modifying the original image (change colors in areas
not working well, change colors overall, etc.) and limiting / extending the
colors (add useful ones, remove expensive ones) until you are satisfied with the
outcome (and price ;) ).
### Import parts to bricklink
1. Login at [https://www.bricklink.com/](https://www.bricklink.com/)
1. Go to __Want > Upload__ (see [here](https://www.bricklink.com/v2/wanted/upload.page))
1. Choose ___Upload BrickLink XML format___
1. Copy & paste (ctrl-a, ctrl-c, ctrl-v) the XML output of the tool into the window
1. _Proceed to verify items_ and add all to a wishlist (please double-check the
items, before ordering)
## Further information
Find some further definitions below.
### Parameters
Find a short explanation of the parameter arguments below.
#### Required arguments
- `--image_file, -i`: the path to the (original) image to process, can be a
_.jpg_ or _.png_ file
#### Optional arguments
- `--color_file`: the csv-file defining the brick-colors to be used (if not
given, colors.csv at script location is attempted), see format description
below
- `--output_directory, -o`: the directory the output image and BOM is written to
(default is current working directory)
- `--spares`: the number of spares to add per color/brick (in bricklink BOM),
just in case of loosing some bricks
- `--size`: the width/height of the image in 1x1 bricks (default is _48x48_ -
same as current Lego art)
- `--grid_cell`: the size of one cell in the helper grid (e.g.: _4x4_), the
helper grid is useful as a guide when finally placing the bricks, it can be
deactivated by specifying _none_
## Color definition
The set of available colors is defined by the csv-file (`--color_file`, see
above). The following information is required.
```text
rgb ; Bricklink Color Name ; Bricklink Color ID ; Bricklink Part ID
255,255,255 ; White ; 1 ; 3024
175,181,199 ; LightBluishGray ; 86 ; 3024
89,93,96 ; DarkBluishGray ; 85 ; 3024
33,33,33 ; Black ; 11 ; 3024
```
This is an example set of colors for a 4 'color' black & white picture using 1x1
plates. The example is already in expected format. The format requires a header
line and semicolons as column delimiters. The values used here should be aligned
with the definitions on bricklink for the export to work properly (see
[https://www.bricklink.com/catalogColors.asp](https://www.bricklink.com/catalogColors.asp)).
More details about each column:
- The first column is the RGB value of the corresponding color. There is no
official definition of these from Lego, thus, use something as close as
possible you can find. I picked the colors defined on the bricklink page.
- The second column is just a recognizable name for the color. Using the
bricklink name seems reasonable.
- The third column is the bricklink color ID (see page mentioned before). This
is important for the XML-export to function properly.
- The fourth column is the bricklink brick type ID. You can find these in
bricklinks database. Since the script only considers 1x1 parts, only these
should be used. The _3024_ from the example is the 1x1 plate (see [here](https://www.bricklink.com/v2/catalog/catalogitem.page?P=3024#T=C)).
Other options include, but are not limited to, 1x1 tiles (3070b, see [here](https://www.bricklink.com/v2/catalog/catalogitem.page?P=3070b#T=C))
or 1x1 plate round (4073, see [here](https://www.bricklink.com/v2/catalog/catalogitem.page?P=4073#T=C)).
Note that prices vary _a lot_ with color **AND** brick type. For my own mosaic
I used 1x1 plates, but replaced an expensive color with a much cheaper 1x1
tile.
Raw data
{
"_id": null,
"home_page": null,
"name": "brickmos",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "Marius Merschformann <marius.merschformann@gmail.com>",
"keywords": "bricklink, lego, mosaic",
"author": null,
"author_email": "Marius Merschformann <marius.merschformann@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/84/79/0eeece05ebc813c7135c59364c174cddee5b8bd6e39a9754caaa3c913fe3/brickmos-0.1.1.tar.gz",
"platform": null,
"description": "# brickmos\n\n**brick**-**mos**aic\n\n[![pypi_version](https://img.shields.io/pypi/v/brickmos?label=pypi)](https://pypi.org/project/brickmos)[![build](https://github.com/merschformann/brickmos/actions/workflows/build.yml/badge.svg)](https://github.com/merschformann/brickmos/actions/workflows/build.yml)\n\nThis is a simple tool for converting images to Lego mosaics such that their\nparts can be ordered quite easily from bricklink (https://www.bricklink.com/).\nI wrote this for myself for a birthday present I worked on, but wanted to leave\nit here for others to re-use or as inspiration.\n\n![process-steps](https://raw.githubusercontent.com/merschformann/brickmos/main/material/process-steps.svg)\n\n(ltr: original image, pixelated image with original color, image with colors\nmapped to given Lego colors; [image source](https://www.vincenthie.com/gallery/disney/ironmanportrait)) \n\n## Motivation & alternatives\n\nThis is a rather simple script which worked well for me, as I went back and\nforth between my image editing tool and modifying the color pallet. I really\nlike this continuous process of shaping the result while keeping colors/brick\ntypes and their prices under control. I even ended up replacing one 1x1 plate\nwith a 1x1 tile, since the respective color was too expensive on bricklink.\nFurthermore, I was only interested in full 1x1 mosaics, similar to the Lego\nmosaic art product line. I also ended up buying the frame parts used for the\nLego art frame, as it is extendable and easily wall-mountable (see [here](https://www.lego.com/de-de/campaigns/art/)).\n\nHowever, if you are more interested in a GUI application, different workflow or\nautomatically chosen larger than 1x1 pixels, you may want to have a look at the\nfollowing alternatives (if I forgot an alternative here, let me know):\n\n- Bricklink studio (full-blown brick set designer with a mosaic feature, (see\n [here](https://www.bricklink.com/v3/studio/download.page))\n- PicToBrick (specifically made for brick mosaics, see [here](http://www.pictobrick.de/en/pictobrick.shtml))\n\n## Quickstart\n\nThe following should get you started.\n\n### Dependencies\n\nMain dependencies are:\n\n- Python (I used python 3.8)\n - `opencv-python` (the version I used is defined in _requirements.txt_)\n\nIf you run into problems missing `libGL.so`, install the following:\n\n```bash\nsudo apt update\nsudo apt install libgl1-mesa-glx\n```\n\n### Installation\n\nInstall via PyPi\n\n```bash\npip install brickmos --upgrade\n```\n\n### Process an image\n\nConvert an image by invoking the script as follows:\n\n`brickmos --image_file data/iron-man-portrait.jpg --output_directory=\"temp\"`\n\nOr alternatively clone this repo and run it directly:\n\n`python run.py --image_file data/iron-man-portrait.jpg --output_directory=\"temp\"`\n\nRepeat the process while modifying the original image (change colors in areas\nnot working well, change colors overall, etc.) and limiting / extending the\ncolors (add useful ones, remove expensive ones) until you are satisfied with the\noutcome (and price ;) ).\n\n### Import parts to bricklink\n\n1. Login at [https://www.bricklink.com/](https://www.bricklink.com/)\n1. Go to __Want > Upload__ (see [here](https://www.bricklink.com/v2/wanted/upload.page))\n1. Choose ___Upload BrickLink XML format___\n1. Copy & paste (ctrl-a, ctrl-c, ctrl-v) the XML output of the tool into the window\n1. _Proceed to verify items_ and add all to a wishlist (please double-check the\n items, before ordering)\n\n## Further information\n\nFind some further definitions below.\n\n### Parameters\n\nFind a short explanation of the parameter arguments below.\n\n#### Required arguments\n\n- `--image_file, -i`: the path to the (original) image to process, can be a\n _.jpg_ or _.png_ file\n\n#### Optional arguments\n\n- `--color_file`: the csv-file defining the brick-colors to be used (if not\n given, colors.csv at script location is attempted), see format description\n below\n- `--output_directory, -o`: the directory the output image and BOM is written to\n (default is current working directory)\n- `--spares`: the number of spares to add per color/brick (in bricklink BOM),\n just in case of loosing some bricks\n- `--size`: the width/height of the image in 1x1 bricks (default is _48x48_ -\n same as current Lego art)\n- `--grid_cell`: the size of one cell in the helper grid (e.g.: _4x4_), the\n helper grid is useful as a guide when finally placing the bricks, it can be\n deactivated by specifying _none_\n\n## Color definition\n\nThe set of available colors is defined by the csv-file (`--color_file`, see\nabove). The following information is required.\n\n```text\nrgb ; Bricklink Color Name ; Bricklink Color ID ; Bricklink Part ID\n255,255,255 ; White ; 1 ; 3024\n175,181,199 ; LightBluishGray ; 86 ; 3024\n89,93,96 ; DarkBluishGray ; 85 ; 3024\n33,33,33 ; Black ; 11 ; 3024\n```\n\nThis is an example set of colors for a 4 'color' black & white picture using 1x1\nplates. The example is already in expected format. The format requires a header\nline and semicolons as column delimiters. The values used here should be aligned\nwith the definitions on bricklink for the export to work properly (see\n[https://www.bricklink.com/catalogColors.asp](https://www.bricklink.com/catalogColors.asp)).\n\nMore details about each column:\n\n- The first column is the RGB value of the corresponding color. There is no\n official definition of these from Lego, thus, use something as close as\n possible you can find. I picked the colors defined on the bricklink page.\n- The second column is just a recognizable name for the color. Using the\n bricklink name seems reasonable.\n- The third column is the bricklink color ID (see page mentioned before). This\n is important for the XML-export to function properly.\n- The fourth column is the bricklink brick type ID. You can find these in\n bricklinks database. Since the script only considers 1x1 parts, only these\n should be used. The _3024_ from the example is the 1x1 plate (see [here](https://www.bricklink.com/v2/catalog/catalogitem.page?P=3024#T=C)).\n Other options include, but are not limited to, 1x1 tiles (3070b, see [here](https://www.bricklink.com/v2/catalog/catalogitem.page?P=3070b#T=C))\n or 1x1 plate round (4073, see [here](https://www.bricklink.com/v2/catalog/catalogitem.page?P=4073#T=C)).\n Note that prices vary _a lot_ with color **AND** brick type. For my own mosaic\n I used 1x1 plates, but replaced an expensive color with a much cheaper 1x1\n tile. \n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2020 Marius Merschformann 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.",
"summary": "brickmos is a humble Lego mosaic generator.",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/merschformann/brickmos",
"Repository": "https://github.com/merschformann/brickmos"
},
"split_keywords": [
"bricklink",
" lego",
" mosaic"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d29aebdfd7b6a5ee61f070ee92949d9b299d52fe4f03f45ea9240b83e48719fc",
"md5": "1550cde8f8bb435ae964ba7f29207379",
"sha256": "d8494c6595dd58d4a06ced1f7711b2109526ce6cf085763b8e8b22f8d1aad367"
},
"downloads": -1,
"filename": "brickmos-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1550cde8f8bb435ae964ba7f29207379",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 10104,
"upload_time": "2024-09-02T15:40:45",
"upload_time_iso_8601": "2024-09-02T15:40:45.704534Z",
"url": "https://files.pythonhosted.org/packages/d2/9a/ebdfd7b6a5ee61f070ee92949d9b299d52fe4f03f45ea9240b83e48719fc/brickmos-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "84790eeece05ebc813c7135c59364c174cddee5b8bd6e39a9754caaa3c913fe3",
"md5": "683ffdbb2360cfd8d6f1e975c3bd5d4b",
"sha256": "2ac910b97666c084dc1c2f86f145a0accbdd412bc912a0dcd724bffb12db4702"
},
"downloads": -1,
"filename": "brickmos-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "683ffdbb2360cfd8d6f1e975c3bd5d4b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 2432416,
"upload_time": "2024-09-02T15:40:48",
"upload_time_iso_8601": "2024-09-02T15:40:48.292194Z",
"url": "https://files.pythonhosted.org/packages/84/79/0eeece05ebc813c7135c59364c174cddee5b8bd6e39a9754caaa3c913fe3/brickmos-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-02 15:40:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "merschformann",
"github_project": "brickmos",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "brickmos"
}