-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added brick count statistics #99
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2.6 coverage is not a big deal, but if you could fix that, it would be nice. Otherwise just give me back my blank newlines that I hold dear.
legofy/palettes.py
Outdated
@@ -99,7 +152,6 @@ def legos(): | |||
"""Build flattened lego palettes.""" | |||
return _flatten_palettes(LEGOS.copy()) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is really minor. But why did you delete that line.
legofy/__init__.py
Outdated
frames_converted.append(new_frame) | ||
|
||
if stats == True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Protip: instead of if cond == True
use if cond
README.md
Outdated
@@ -43,7 +43,8 @@ Options: | |||
--dither / --no-dither Use dither algorithm to spread the color approximation error. | |||
--palette [all|effects|mono|solid|transparent] | |||
Palette to use based on real Lego colors. | |||
--help Show this message and exit. | |||
--help Show this message and exit.xxsx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edit.xxsx
What?
README.md
Outdated
@@ -43,7 +43,8 @@ Options: | |||
--dither / --no-dither Use dither algorithm to spread the color approximation error. | |||
--palette [all|effects|mono|solid|transparent] | |||
Palette to use based on real Lego colors. | |||
--help Show this message and exit. | |||
--help Show this message and exit.xxsx | |||
--stats Shows the count of brick colors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
place help at bottom
legofy/__init__.py
Outdated
'''Legofy an image''' | ||
new_size = get_new_size(base_image, brick_image, size) | ||
base_image.thumbnail(new_size, Image.ANTIALIAS) | ||
if palette_mode: | ||
palette = get_lego_palette(palette_mode) | ||
base_image = apply_thumbnail_effects(base_image, palette, dither) | ||
make_lego_image(base_image, brick_image).save(output_path) | ||
lego_image, brick_stats = make_lego_image(base_image, brick_image) | ||
if stats == True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if stats
legofy/__init__.py
Outdated
'''Legofy an image''' | ||
new_size = get_new_size(base_image, brick_image, size) | ||
base_image.thumbnail(new_size, Image.ANTIALIAS) | ||
if palette_mode: | ||
palette = get_lego_palette(palette_mode) | ||
base_image = apply_thumbnail_effects(base_image, palette, dither) | ||
make_lego_image(base_image, brick_image).save(output_path) | ||
lego_image, brick_stats = make_lego_image(base_image, brick_image) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add newlines to clearly show where if statements end and to improve readability
legofy/__init__.py
Outdated
lego_image, brick_stats = make_lego_image(base_image, brick_image) | ||
if stats == True: | ||
print(brick_stats) | ||
lego_image.save(output_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, add a newline
Really like that you decided to make a pull request to this old project. Been dead for a while. Glad you took some interest to it. |
Some of these mistakes were from just last night coding. This was a really fun project and I thought I would contribute to it. |
for brick_x in range(base_width): | ||
for brick_y in range(base_height): | ||
color = rgb_image.getpixel((brick_x, brick_y)) | ||
|
||
'''Increment color count''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so im not sure whats going on here completely. But wouldn't this not cover some colors? As in, if some colors in the image aren't in LEGOS_LABEL
, it wouldn't count them? Also, why are you doing
if str(palettes.LEGOS_LABEL[color_label]['rgb']) == str(color):
You could just compare the literal r g b values as ints rather than converting to str.
#98 Feature request: displays counts of brick with colors
example:
legofy --stats --palette all image.jpg