When you want or need a custom tool and you can’t find it, you have two options: you either buy one (or ask someone to build it for you), or you make your own and do the best you can to make it work for you. This week, I decided to start building my own (almost pure Python) utility to optimize images for the web.
Python is an amazing language that can be both forgiving for beginners and still provide more and more advanced features as we dig through. Sometimes, you hear or read about some of its powerfull tools, and you feel that you have nothing to use it on. But one day that time comes, and you realise that it can make things easier, more readable or more performant. Generators are one of those nice little things.
Since I started discovering Python about two years ago, my learning path has been made of a lot of small steps. And today was no exception (no Python pun intended).
While working on this website, I had the curiosity to find out how many HTML and image files Pelican was generating behind the scenes. I had no utility at hand to count files recursively through folders and subfolders, so I decided to create my own using Python.
Every year, on the 25th April, Portugal celebrates in a very enthusiastic way the Freedom Day, keeping alive the memory of that day on 1974, when our country got liberated from an authoritarian and oppressive dictatorial regimen. It’s one of our most important national holidays and even those of us who were born some time after the end of the dictatorship, we still value that important conquest made by our parents.
Making this website load fast while looking good is one of my goals. But making sure that high resolution images don’t weight more that necessary is not that easy, especially when you’re writing your content on iOS and in Markdown…