python 5 min read

Presenting "AQI Visualizer" for Zoom! (Not just for Delhiites)

A colleague asked if my smoggy Zoom background was a live AQI feed. One night of scope creep later, I had a Python CLI that uses DALL-E 3 to paint your city at its real AQI.

I know, I know. The last night rains have helped a lot to bring AQI down! ⛈️

Story Time

Yesterday, while on a monthly team AMA call, I decided to embrace Delhi’s pollution by having a virtual background that represents the actual AQI around me.

Me on a Zoom call, looking glum in front of a virtual background of India Gate shrouded in orange smog
At least we have good roads? Amrite?

While on this call, I received an interesting DM from a colleague asking:

“Hey Jatin! Is your background the real time AQI feed for Delhi?“

💡 I laughed and said “No! But that’s a great idea!“!


I present to you, how a one-liner problem can be a slippery slope, when it comes to scope creep, especially when you are passionate about it!

Here’s how this project took shape my in mind in just a few hours post-work last night:

v0.1 // Just hard-code images!

Google Images results for "india gate rajpath", a grid of photos of India Gate seen from Rajpath

  • Let’s just save 5 images of India Gate taken from Rajpath and store them in a directory.
  • We can then fetch AQI from an API and based on the range: 0-100, 100-200……500+, we can just pick the relevant one to showcase how bad the air is.
  • Set it as Zoom background using a cron job, maybe every 4 hours?

This is just too easy for a principal engineer. Right? 😜

v0.2 // Day & Night?

scopeCreep*=5

  • Well, now that we have a list of images stored on my local dir, why stop at just 5? Can we also change the lighting to reflect what time of day it is?
  • So, grouping by let’s say 4 phases in a day, I now need 20 images.
    • Morning x 5 AQI buckets
    • Afternoon x 5 AQI buckets
    • Evening x 5 AQI buckets
    • Night x 5 AQI buckets
  • But finding images with different AQI will be not easy especially in batches of these phases of the day especially just for India Gate. 🤔
  • What if I can just use 4 sample images for different times and just add a Gaussian blur using Pillow to represent AQI? Quick script!

A tiny Pillow script, blurr.py, open in vim: it opens india_gate.jpeg and applies ImageFilter.BoxBlur(5)

Code ⬇️
# Importing Image class from PIL module
from PIL import Image
 
# Opens a image in RGB mode
im = Image.open(r"india_gate.jpg")
 
# Blurring the image
im1 = im.filter(ImageFilter.BoxBlur(4))
 
# Shows the image in image viewer
im1.show()
Input Output with ImageFilter.BoxBlur(5)
India Gate on a clear day The same India Gate photo with a box blur applied to fake smog

v0.3 // But why just India Gate? 🤔

scopeCreep*=50

  • This looks good, but what if Delhi people don’t like India Gate? 😂
    • Maybe we should pick Red Fort, Qutub Minar, Old Fort etc. ?

I will let you think about complexity!

v0.4 // Why just Delhi? 😬

scopeCreep*=500

  • People live in other cities as well. We have the iconic Gateway of India, the Taj Mahal, Charminar, Hawa Mahal, Victoria Memorial, Khajuraho temples etc.
  • That would look really cool!

v0.5 // Why just India? 🧠

scopeCreep*=10000

  • Folks live in other countries as well! Statue of Liberty, the Great Wall of China, Christ the Redeemer, Machu Picchu, The Great Pyramid of Giza, the Eiffel Tower, The Colosseum, Angkor Wat etc.
  • That would be epic!!!
  • But………deadend! 💀

This got me thinking!

Only if there was a way to generate an image on the fly with exactly the specifications I want that can change dynamically! Hmm…..you know where this is going!

🤖 ARTIFICIAL INTELLIGENCE 🤖

* DALL-E 3 has entered the chat *

Side-by-side comparison of DALL-E 2 and DALL-E 3 output for "an expressive oil painting of a basketball player dunking, depicted as an explosion of a nebula"

v0.1 // Presenting aqi-visualizer 🥁

scopeCreep*=∞

So, I fired up a Jupyter Notebook so I could iterate peacefully.

Jupyter notebook prototype that fetches Delhi's AQI from the WAQI API and calls DALL-E 3 to generate a 1792x1024 landscape image; the cell holding the API tokens is blanked out
No, I didn’t check in my code with token. Yes! I have added code to fetch tokens from env vars!

Once I had the POC working, ended up pulling off a hackathon last night, refactored by script into a proper project following SOLID principals 😛 and built this using Python, AQICN and DALL-E 3 🤓

https://github.com/jatinkrmalik/aqi-visualizer

It basically is a Python CLI tool that can:

  • accept location as --city param (default to automatically find your location by IP)
  • find your city’s AQI
  • generate a landscape image from your city’s popular monument/destination with that AQI number using OpenAI’s DALL-E 3,
  • Add a text overlay to generated images (can also accept --text for custom overlay)
  • Stores the image to the current working dir, or you can give --output param.

Here’s a sample run:

Terminal running main.py --city "Kolkata": it fetches AQI 197, generates the image via the OpenAI API, adds the text overlay and saves Kolkata_197.png; the signed image download URL is blanked out
It’s fairly easy to set up: https://github.com/jatinkrmalik/aqi-visualizer#installation

Output? Here you go!


Finally!

A night well spent coding! Now I can be disappointed with the quality of air I am breathing in real time while my air purifier struggles to keep up! 😿

Me smiling and pointing up on a Zoom call in front of the generated "Old Delhi // 269" background
But hey! At least my Zoom background is more realistic-ish…?!

I have logged some issues/enhancements on the github project. I might spend some time on weekends on over-engineer this to make it more customizable!

If you would like to contribute, feel free to fork and send a PR over for:

https://github.com/jatinkrmalik/aqi-visualizer

Comments

    Supports `code`, ```blocks```, **bold**, *italics* and links.

    Keep reading

    ai 6 min

    I filed my Indian taxes as an NRI with AI agents

    My first time self-filing an ITR, done end to end with Grok 4.5 in the grok build CLI. I built a neo-brutalist dashboard and a 158-page audit packet, and still overpaid by ₹5,550.