
My wife, Denise, recently joined her church choir, and her beautiful voice deserved equally clear sheet music for practice. The songs came in small, trade paperback-sized booklets, printed on challenging yellow paper. Her goal was straightforward: scan these booklets, remove the distracting yellow background, and reprint the music larger on standard 8.5-by-11-inch paper, eliminating the need for her reading glasses.
The yellow background presented a significant problem, not just for readability but also for printing costs. Printing directly would mean wasting vast amounts of color ink, or a lot of gray ink if converted to black and white, making the music even harder to see. Beyond printing, she also planned to feed the scores into PlayScore 2, an app that plays sheet music, and was concerned the background color might interfere with its interpretation.
Navigating the Pitfalls of Direct AI Editing
My first thought was Adobe Photoshop, but quickly realized it was too cumbersome. Each image required slightly different slider adjustments, turning a simple task into an annoying, time-consuming chore. That’s when I turned to ChatGPT, a tool my wife already used with her Plus account, hoping it could offer a quicker solution.
My initial prompts to ChatGPT were direct: “Give me back a PDF I can download where the yellow background has been removed and replaced with white.” While it worked, the quality was disappointingly low-resolution. A follow-up prompt for full resolution also succeeded, but a critical issue emerged.
My wife noticed that ChatGPT subtly altered the resulting PDFs, changing minor details in the notes or words. This was a deal-breaker; she absolutely couldn’t risk the AI taking liberties with her music, especially when sight-reading and practicing. This experience highlighted a fundamental characteristic of artificial intelligence: its non-deterministic nature.
Unlike traditional algorithmic programming, where the same input always yields the same predictable output (deterministic), AIs like ChatGPT operate on complex probability calculations. This means you could feed the exact same data multiple times and receive different results each instance. For tasks requiring absolute fidelity to the source material, this variability is a significant concern, making direct AI editing of sensitive files unreliable.
Building a Reliable Solution with AI
Knowing that Python possessed the necessary libraries for image transformation from a previous Harvard certification project, I saw a path forward. I didn’t have the time to write a custom Python script myself that week, but I realized ChatGPT had all the time in the world. This presented an exciting opportunity: using a non-deterministic tool like ChatGPT to generate a deterministic program.
My approach shifted from asking AI to edit files directly to asking it to *write the software* that would do the editing reliably. I crafted a specific prompt for ChatGPT, outlining exactly what I needed: “Write a python script that takes in a jpeg and sets any pixels that are not gray or black to white, saving it back out as name-decolor.jpg where name is the file name. Allow slightly tinted grays so that black text on a colored background will render properly as black text. Can you do the same thing if a PDF is presented? It also needs to work if the PDF is multiple pages.”
I entered the prompt and then went to help my wife prepare dinner. By the time we were done, ChatGPT had delivered. The first version of the script required installing a single Python library, but after that, it ran flawlessly. This ingenious method allowed me to leverage AI’s rapid code generation while maintaining the precision and predictability essential for sensitive documents.
The Power of AI-Generated Deterministic Tools
The resulting Python script, named decolor_pdf.py, works with elegant simplicity. You execute it from the command line, feeding it a single PDF file, and it outputs a new PDF with the background color seamlessly removed. It’s a precise, reliable, and entirely predictable tool, perfectly addressing my wife’s initial concerns about file alteration.
To demonstrate its effectiveness without using copyrighted material, I sourced a public domain song by the legendary jazz artist Fats Waller from the New York Public Library’s website. The script effortlessly transformed the original, allowing for crisp, clear printing and digital use.
This experience offered several powerful takeaways for anyone looking to harness AI effectively:
- AI, particularly large language models like ChatGPT, can be an incredible resource for rapid software development, even for custom tools.
- While direct AI interaction with critical files carries risks due to its non-deterministic nature, it excels at generating deterministic code.
- By having AI write a script, you gain a repeatable, controllable solution that processes files precisely as instructed, without subtle alterations.
- Sometimes, the smartest way to use advanced AI isn’t to let it touch your files, but to ask it to build you the software that handles them safely.
So, if you find yourself needing a quick, custom software solution for a precise task, consider asking ChatGPT to write the program for you. It worked for me, providing my wife with a perfect tool for her choir music, all while I helped make dinner!
Source: ZDNet – AI