-
Notifications
You must be signed in to change notification settings - Fork 9
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
Image Conversion being too slow #1
Comments
Thanks for the feedback! I took a look at this, and it looks like most expensive part occurs for non- TL;DR: Use Some cProfile stats, sorted by the total time spent in each line, for the input: convert('image.png', is_unicode=True, width=100)
Now, it's much different for this: convert('image.png', is_unicode=True, width=100, is_truecolor=True, is_256color=False) Note, yeah, I notice that it's kinda annoying to enable truecolour, using default values gets in the way here. Log:
I benchmarked a bunch of different invocations, too: duration = timeit.timeit(lambda: convert('image.png', is_unicode=True, width=2, is_truecolor=True, is_256color=False), number=1000)
print(f"Width=2 (unicode, truecolor) took {duration}")
duration = timeit.timeit(lambda: convert('image.png', is_unicode=True, width=100, is_truecolor=True, is_256color=False), number=1000)
print(f"Width=100 (unicode, truecolor) took {duration}")
duration = timeit.timeit(lambda: convert('image.png', is_unicode=True, width=2, is_truecolor=False, is_256color=True), number=1000)
print(f"Width=2 (unicode, 256color) took {duration}")
duration = timeit.timeit(lambda: convert('image.png', is_unicode=True, width=100, is_truecolor=False, is_256color=True), number=1000)
print(f"Width=100 (unicode, 256color) took {duration}")
duration = timeit.timeit(lambda: convert('image.png', is_unicode=False, width=2, is_truecolor=True, is_256color=False), number=1000)
print(f"Width=2 (truecolor) took {duration}")
duration = timeit.timeit(lambda: convert('image.png', is_unicode=False, width=100, is_truecolor=True, is_256color=False), number=1000)
print(f"Width=100 (truecolor) took {duration}")
duration = timeit.timeit(lambda: convert('image.png', is_unicode=False, width=2, is_truecolor=False, is_256color=True), number=1000)
print(f"Width=2 (256color) took {duration}")
duration = timeit.timeit(lambda: convert('image.png', is_unicode=False, width=100, is_truecolor=False, is_256color=True), number=1000)
print(f"Width=100 (256color) took {duration}") Prints (this is the time each function call takes, in milliseconds):
Which is confirming that the part that's mapping colours from the image to terminal colours is a bit slow. I might try and re-implement it in C++, or investigate different data-structures, because Python's just kinda slow at it. :/ |
Thanks, adding |
Haha, don't worry about closing the issue, I'm still looking to fix the performance issues for 256 bit colour, just haven't had the time quite yet :) Thanks again for pointing it out! |
Okay, sorry. That's cool then. Thanks 👍 |
Hey, I really love this tool.
Its able to accurately convert images to terminal codes.
But I have one issue - the conversion process is too slow....
Here is an example:
ORIGINAL -
500x500_random.png
Command:
climage.convert("500x500_random.png", is_unicode=True, width=100)
OUTPUT -
And this conversion took about 0.51 seconds.
My original idea was to try to make a real-time video-transmission tool using only the terminal.
But the output video cannot be like 2 FPS....
So is there any way to optimize the conversion process without losing a lot of quality?
The text was updated successfully, but these errors were encountered: