Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
New project: yet another [almost pure Python] image optimizer
-
As you know, I have been trying to build and publish one of my websites from either my Mac or my iPhone. For that specific website, I write my content in Markdown, and then I use Pelican and a couple of Python and shell scripts to build the static HTML with the correct file and folder structure and, finally, to upload the website through FTP. This week, I decided to start building my own (almost pure Python) utility to optimize images for the web.
I know that image optimization algorithms are a pretty technical subject, and I certainly won’t be able to come out with a Python implementation of any of the mentioned binary utilities. However I will still try to find out if there is any other kind of optimization that can be done using the Python tools available or installable in Pythonista.
Check it out:
https://no-title.victordomingos.com/articles/2018/new_python_project_optimize-images/As always, if you have some nice tip and want to contribute, I will certainly appreciate it very much! :)
-
cool, maybe make it nonblocking so you can add stuff while it works
-
Right. I plan to make it multithreaded soon. It should improve a bit without making it a lot more complex.
At this time, however, I am more focused in exploring the existing possibilities regarding the image compression itself. Unfortunately, most stuff I find on the web depends on binaries or some packages that aren’t compatible with Pythonista.
-
I did a quick experiment using
concurrent.futures
but it seems that on Pythonista in this case the performance improvements are very small. And that makes sense, because code inside Pythonista can’t use more than one process, and using threads here shouldn’t have a big impact as this image optimization is a cpu bound task, more than I/O bound. Right? -
On the other hand, using multiprocessing on desktop did indeed reduce noticeably the overall processing time. So I decided to include it as a conditional feature, after platform detection.
If I decide to implement later an optimization routine based on a web API, threading or async I/O will definitely be required.
-
@ellie_ff1493 I have just announced the first public release, and in fact, looking back, it seems that doing multithreaded processing on iOS did improve significantly its performance. On desktop I went with multiprocessing, though, as it allows even better speed on this kind of tasks.
Thanks for the feedback!
Check it out:
Optimize Images – check out the first public release! -
A new update:
Optimize Images v1.1 – new features