juanpotato / legofy Goto Github PK
View Code? Open in Web Editor NEWMake images look as if they are made out of 1x1 LEGO blocks
License: MIT License
Make images look as if they are made out of 1x1 LEGO blocks
License: MIT License
Please add ability to adjust "resolution" of the output image. I don't necessary mean the output size of the brick, more that the image size of the output changes to include less or more detail of the original.
Can't find project's description. Sorry.
And also generate a parts list.
Added here for discussion :D I realize this could be a lot of work. But the payoff! Oh, the payoff!
It's hard to contribute or use this since there is no license file
Any gifs that are optimized and have pieces of frames deleted will form broken gifs once legofied. By broken I mean that the frames will look glitchy. I found this and will implement it tomorrow, if anyone finds anything better, please tell me.
I ran the following: sudo python setup.py install
and at the end of the program I got this ValueError: --enable-jpeg requested but jpeg not found, aborting.
Is there a jpeg missing?
Could you please update the 1x1 brick to high-res image?
Putting this here for conversation and progress
Text:
Working on frame_0328.png Working on frame_0329.png Working on frame_0330.png Working on frame_0331.png convert -delay 4 -loop 0 ./tmp_frames/*.png /Users/k1lly/Pictures/lego_1.gif Traceback (most recent call last): File "/usr/local/bin/legofy", line 9, in <module> load_entry_point('legofy==0.0.1', 'console_scripts', 'legofy')() File "/Library/Python/2.7/site-packages/click-5.1-py2.7.egg/click/core.py", line 700, in __call__ return self.main(*args, **kwargs) File "/Library/Python/2.7/site-packages/click-5.1-py2.7.egg/click/core.py", line 680, in main rv = self.invoke(ctx) File "/Library/Python/2.7/site-packages/click-5.1-py2.7.egg/click/core.py", line 873, in invoke return ctx.invoke(self.callback, **ctx.params) File "/Library/Python/2.7/site-packages/click-5.1-py2.7.egg/click/core.py", line 508, in invoke return callback(*args, **kwargs) File "/Library/Python/2.7/site-packages/legofy-0.0.1-py2.7.egg/legofy/cli.py", line 13, in main legofy.main(image) File "/Library/Python/2.7/site-packages/legofy-0.0.1-py2.7.egg/legofy/__init__.py", line 133, in main call(command.split(" ")) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call return Popen(*popenargs, **kwargs).wait() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__ errread, errwrite) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory server:Pictures k1lly$
Normally, when I try a new project, I don't install it, but Legofy don't seem to let me to run it directly, using 616af86.
I have tried:
python legofy/__init__.py
python legofy/cli.py
python -m legofy.__init__
Which is expected, nothing happens as the code doesn't do anything in running this way. Do I have to install for entry point script in order to try it out?
I installed with
pip install --user .
But, the asset bricks/brick.png
isn't installed:
% legofy spinner.gif
Animated gif detected, will now legofy each frame and recreate the gif and save as lego_spinner.gif
Working on frame_0003.png
Traceback (most recent call last):
File "/home/livibetter/.local/bin/legofy", line 9, in <module>
load_entry_point('legofy==0.0.1', 'console_scripts', 'legofy')()
[snip]
File "/home/livibetter/.local/lib64/python2.7/site-packages/legofy/__init__.py", line 54, in makeLegoBrick
return applyEffect(Image.open(brick), colorize)
File "/usr/lib64/python2.7/site-packages/PIL/Image.py", line 2248, in open
fp = builtins.open(fp, "rb")
IOError: [Errno 2] No such file or directory: '/home/livibetter/.local/lib64/python2.7/site-packages/legofy/bricks/brick.png'
So, I tried with --brick
, but here
isn't defined when run with the option, hence:
% legofy --brick /tmp/Legofy/legofy/bricks/brick.png spinner.gif
Traceback (most recent call last):
File "/home/livibetter/.local/bin/legofy", line 9, in <module>
load_entry_point('legofy==0.0.1', 'console_scripts', 'legofy')()
[snip]
File "/home/livibetter/.local/lib64/python2.7/site-packages/legofy/cli.py", line 13, in main
legofy.main(image, brick=os.path.join(here, 'bricks', 'brick.png'))
UnboundLocalError: local variable 'here' referenced before assignment
Hello,
using python 2.7.6, when I run the script, I get errors in init.py when closing the files on :
https://github.com/JuanPotato/Legofy/blob/master/legofy/__init__.py#L177-L178
According to this discussion it seems that closing is not needed, no? Can this be removed or is there any particular reason you have done it?
I get the following error when running legofy
from the command line: AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'
After some quick Googling, it appears that this is an issue with PIL having deprecated this method.
This makes maintenance easier.
Cannot get it to run, because of
TypeError
$ python legofy/cli.py nexmo.png
Static image detected, will now legofy and save as /lego_nexmo.png
Traceback (most recent call last):
File "legofy/cli.py", line 17, in <module>
main()
File "/Library/Python/2.7/site-packages/click/core.py", line 700, in __call__
return self.main(*args, **kwargs)
File "/Library/Python/2.7/site-packages/click/core.py", line 680, in main
rv = self.invoke(ctx)
File "/Library/Python/2.7/site-packages/click/core.py", line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Python/2.7/site-packages/click/core.py", line 508, in invoke
return callback(*args, **kwargs)
File "legofy/cli.py", line 14, in main
legofy.main(image, brick=brick)
File "/Library/Python/2.7/site-packages/legofy-0.0.1-py2.7.egg/legofy/__init__.py", line 131, in main
makeLegoImage(baseImage, brick).save(newFilename)
File "/Library/Python/2.7/site-packages/legofy-0.0.1-py2.7.egg/legofy/__init__.py", line 67, in makeLegoImage
legoImage.paste(makeLegoBrick(brick, bp[0], bp[1], bp[2]), (x * width, y * height, (x + 1) * width, (y + 1) * height))
TypeError: 'int' object has no attribute '__getitem__'
I try to run setup.py but the system is ignoring me,
Please fix
Here is my terminal :
$ python setup.py install
running install
Checking .pth file support in /Library/Python/2.7/site-packages/
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-31852.pth'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/Library/Python/2.7/site-packages/
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
https://pythonhosted.org/setuptools/easy_install.html
Please make the appropriate changes for your system and try again.
$ legofy
Traceback (most recent call last):
File "/usr/local/bin/legofy", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2793, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 673, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 576, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pillow
Coverage should be better.
Remove cli.py from coverage or add a test to add coverage to it.
I tried to add a test but failed to get it working with click.
Two ideas:
difusse
and normal-map
. This way people can add lighting on post-production and better fake a lego-video.For example, each lego block in the output image is essentially a pixel. The user should be able to specify the new "resolution" for their image as a command line option.
Hi,
I have a generall question regarding ImageImagick. Why did you decide to implement it? As far as I remember script worked without it.
I usually see external tools and bridges as a major design flow because of lack of flexibility and dependency on external provider. Perhaps there is a good reason for imagemagick?
Best regards
@click.argument('output', default=None, required=False)
def main(brick, image, output):
# [..]
.. but then it's not passed to anything (or used).
• System Information: Model: Mac Mini (Late 2014)
• CPU: Intel Core i5-4278U (4 Threads, 2 Cores) @ 2.60 GHz
• Memory: 8.00 GB • Uptime: 5 hours • Disk Space: 998.98 GB
• Graphics: Intel Iris
• Screen Resolution: 1920 x 1080
• OS: OS X El Capitan (Version 10.11.1, Build 15B42)
15.0.0 Darwin Kernel Version 15.0.0: Sat Sep 19 15:53:46 PDT 2015; root:xnu-3247.10.11~1/RELEASE_X86_64 x86_64
Animated gif detected, will now legofy each frame and recreate the gif and save as lego_pixel_waterfall_bg__by_isohei-d4xntof.gif
Working on frame_0000.png
Working on frame_0001.png
Working on frame_0002.png
Working on frame_0003.png
Working on frame_0004.png
Working on frame_0005.png
Working on frame_0006.png
Working on frame_0007.png
convert -delay 10 -loop 0 ./tmp_frames/*.png /lego_pixel_waterfall_bg__by_isohei-d4xntof.gif
Traceback (most recent call last):
File "/usr/local/bin/legofy", line 9, in <module>
load_entry_point('legofy==0.0.1', 'console_scripts', 'legofy')()
File "/Library/Python/2.7/site-packages/click/core.py", line 700, in __call__
return self.main(*args, **kwargs)
File "/Library/Python/2.7/site-packages/click/core.py", line 680, in main
rv = self.invoke(ctx)
File "/Library/Python/2.7/site-packages/click/core.py", line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Python/2.7/site-packages/click/core.py", line 508, in invoke
return callback(*args, **kwargs)
File "/Library/Python/2.7/site-packages/legofy-0.0.1-py2.7.egg/legofy/cli.py", line 14, in main
legofy.main(image, brick=brick)
File "/Library/Python/2.7/site-packages/legofy-0.0.1-py2.7.egg/legofy/__init__.py", line 119, in main
call(command.split(" "))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Hi,
legofy tries to write the new image to /. Results in a permission denied error.
$ python legofy/cli.py 2014-08-08.jpg
Static image detected, will now legofy and save as /lego_2014-08-08.png
Traceback (most recent call last):
File "legofy/cli.py", line 17, in <module>
main()
File "/home/dan/workspace/playground/legofy/lib/python3.5/site-packages/click/core.py", line 700, in __call__
return self.main(*args, **kwargs)
File "/home/dan/workspace/playground/legofy/lib/python3.5/site-packages/click/core.py", line 680, in main
rv = self.invoke(ctx)
File "/home/dan/workspace/playground/legofy/lib/python3.5/site-packages/click/core.py", line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/dan/workspace/playground/legofy/lib/python3.5/site-packages/click/core.py", line 508, in invoke
return callback(*args, **kwargs)
File "legofy/cli.py", line 14, in main
legofy.main(image, brick=brick)
File "/home/dan/workspace/playground/legofy/lib/python3.5/site-packages/legofy-0.0.1-py3.5.egg/legofy/__init__.py", line 131, in main
makeLegoImage(baseImage, brick).save(newFilename)
File "/home/dan/workspace/playground/legofy/lib/python3.5/site-packages/PIL/Image.py", line 1659, in save
fp = builtins.open(filename, "wb")
PermissionError: [Errno 13] Permission denied: '/lego_2014-08-08.png'
BETTER ones... If anyone with photoshop knowledge could recreate a 1x1 lego piece and/or create the 2x1 and 1x2 pieces? I was hoping to have a brand new piece so that I can make sure the base color of the lego is 128,128,128
So far I always used py2exe - do you guys know better alternative that works with tkinter?
Hello @JuanPotato , today while exploring GitHub looking for interesting projects found yours and I would love to contribute by designing a logo for it. I'm a designer in development and an open source enthusiast. We would be working together to create the design that fits best. Of course it's totally free and you can quit whenever you want. In case you agree, please let me know any preferences you may have about colors, shapes, etc.
Kind regards.
Run:
$ legofy /home/xxx/Imágenes/4.jpg
Get Error:
Traceback (most recent call last):
File "/usr/local/bin/legofy", line 9, in <module>
load_entry_point('legofy==0.0.1', 'console_scripts', 'legofy')()
File "/usr/lib/python2.7/dist-packages/click/core.py", line 700, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/click/core.py", line 680, in main
rv = self.invoke(ctx)
File "/usr/lib/python2.7/dist-packages/click/core.py", line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python2.7/dist-packages/click/core.py", line 508, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/legofy-0.0.1-py2.7.egg/legofy/cli.py", line 16, in main
legofy.main(image, brick=brick)
File "/usr/local/lib/python2.7/dist-packages/legofy-0.0.1-py2.7.egg/legofy/__init__.py", line 84, in main
newFilename = '{0}/lego_{1}'.format(*os.path.split(filename))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 13: ordinal not in range(128)
PyPI - the Python Package Index would allow people to do pip install legofy
I am trying to convert an image and getting this error
$ legofy wait-what.jpg
Static image detected, will now legofy and save as /lego_wait-what.png
Traceback (most recent call last):
File "/home/anand/.virtualenvs/3/bin/legofy", line 9, in <module>
load_entry_point('legofy==0.0.1', 'console_scripts', 'legofy')()
File "/home/anand/.virtualenvs/3/lib/python3.4/site-packages/click-5.1-py3.4.egg/click/core.py", line 700, in __call__
File "/home/anand/.virtualenvs/3/lib/python3.4/site-packages/click-5.1-py3.4.egg/click/core.py", line 680, in main
File "/home/anand/.virtualenvs/3/lib/python3.4/site-packages/click-5.1-py3.4.egg/click/core.py", line 873, in invoke
File "/home/anand/.virtualenvs/3/lib/python3.4/site-packages/click-5.1-py3.4.egg/click/core.py", line 508, in invoke
File "/home/anand/.virtualenvs/3/lib/python3.4/site-packages/legofy-0.0.1-py3.4.egg/legofy/cli.py", line 14, in main
File "/home/anand/.virtualenvs/3/lib/python3.4/site-packages/legofy-0.0.1-py3.4.egg/legofy/__init__.py", line 131, in main
File "/home/anand/.virtualenvs/3/lib/python3.4/site-packages/legofy-0.0.1-py3.4.egg/legofy/__init__.py", line 67, in makeLegoImage
File "/home/anand/.virtualenvs/3/lib/python3.4/site-packages/legofy-0.0.1-py3.4.egg/legofy/__init__.py", line 54, in makeLegoBrick
File "/home/anand/.virtualenvs/3/lib/python3.4/site-packages/PIL/Image.py", line 2249, in open
fp = builtins.open(filename, "rb")
NotADirectoryError: [Errno 20] Not a directory: '/home/anand/.virtualenvs/3/lib/python3.4/site-packages/legofy-0.0.1-py3.4.egg/legofy/bricks/brick.png'
I tried to convert this gif from libtiff package:
https://drive.google.com/file/d/0B-4dcK3QuA_LQzc2S3cxcEZYTUE/view?usp=sharing
and got this stacktrace:
$ legofy ring.gif out.gif
Static image detected, will now legofy to /home/jightuse/code/projects/Legofy/out.png
Traceback (most recent call last):
File "/home/jightuse//.local/bin/legofy", line 9, in <module>
load_entry_point('legofy==0.0.1', 'console_scripts', 'legofy')()
File "/home/jightuse/.local/lib/python2.7/site-packages/click-5.1-py2.7.egg/click/core.py", line 700, in __call__
return self.main(*args, **kwargs)
File "/home/jightuse/.local/lib/python2.7/site-packages/click-5.1-py2.7.egg/click/core.py", line 680, in main
rv = self.invoke(ctx)
File "/home/jightuse/.local/lib/python2.7/site-packages/click-5.1-py2.7.egg/click/core.py", line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/jightuse/.local/lib/python2.7/site-packages/click-5.1-py2.7.egg/click/core.py", line 508, in invoke
return callback(*args, **kwargs)
File "/home/jightuse/.local/lib/python2.7/site-packages/legofy-0.0.1-py2.7.egg/legofy/cli.py", line 19, in main
legofy.main(image, output=output)
File "/home/jightuse/.local/lib/python2.7/site-packages/legofy-0.0.1-py2.7.egg/legofy/__init__.py", line 189, in main
legofy_image(base_image, brick_image, output_path)
File "/home/jightuse/.local/lib/python2.7/site-packages/legofy-0.0.1-py2.7.egg/legofy/__init__.py", line 149, in legofy_image
make_lego_image(base_image, brick_image).save(output_path)
File "/home/jightuse/.local/lib/python2.7/site-packages/legofy-0.0.1-py2.7.egg/legofy/__init__.py", line 58, in make_lego_image
lego_image.paste(make_lego_brick(brick_image, bp[0], bp[1], bp[2]), (x * brick_width, y * brick_height, (x + 1) * brick_width, (y + 1) * brick_height))
TypeError: 'int' object has no attribute '__getitem__'
Maybe, it would be really nice to save (with param --statistics or whatever) counts of brick with colors. Something like
red: 5; blue: 50
I really love this project and I would like to create real Lego picture from my photo, but counting brick.. hmmm.. :)
Thanks!
Ajaxovic
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.