I wrote this to demo a quick #Python#Pillow#PIL conversion of an image to grayscale with a dialog to select the file... then applied it to a picture of me and @rennerocha
taken by John as we were flying back home after wonderful #PyConUS24 :)
from tkinter.filedialog import askopenfilename<br></br>from pathlib import Path<br></br><br></br>from PIL import Image<br></br><br></br># Open a select file dialog (a bit ugly on my OS)<br></br>file_path_str = askopenfilename() # '' if cancelled<br></br>if file_path_str: # guards against a cancelled dialog<br></br> file_path = Path(file_path_str) # a pathlib.Path object from the str<br></br> new_name = file_path.stem + '_altered' + file_path.suffix # keep suffix<br></br> # Make it output a PNG if you want LA mode to keep alpha<br></br> # new_name = file_path.stem + '_altered.png' maybe I should check for PNGs?<br></br> output_path = file_path.parent / new_name<br></br> try: # to handle any exceptions (runtime errors while converting/saving)<br></br> with Image.open(file_path) as im: # load image<br></br> altered_im = im.convert('L') # to grayscale (use 'LA' to keep alpha)<br></br> altered_im.save(output_path) # save image<br></br> print(f'Saved {output_path.name}!')<br></br> except Exception as err: # ... treat exception<br></br> print(err)<br></br>
Well, another #PyConUS is done (for me - #Sprints continue for another couple of days!)
It was excellent catching up with old friends and meeting tons of new ones. Pittsburgh was definitely a super cool vibe, 2025 should be fun too.
I'm looking forward to recharging my depleted physical batteries, so I can jump into all the important work we have ahead of us to continue to support this amazing community.
Hey folks, one last entreaty before the #PyConUS hashtag trails off.
We could really use your financial support. Our non-profit #ScholarshipFund is the travel sponsor for #PyCon US 2024.
We've recouped only 4% of what we gave. We're here to serve & happy to do it but could really use some boosts across the fediverse to drive donors so we can do it again.
Pls donate to help more people experience #Pittsburgh through tech conference travel:
💻 pip install ncompare and get started comparing the structure of two NetCDF datasets!
ncompare, a Python package in the pyOpenSci ecosystem, created by Daniel Kaufman, generates a view of the matching and non-matching groups and variables between two NetCDF datasets.
I fixed this bug in my code yesterday but I'm sitting here crying laughing about it today. Godot The Game Engine You've Been Waiting For really said with its whole chest, THAT NULL CHECK CAN'T STOP ME BECAUSE I CAN'T READ #indiedev#gamedev#python#godot#godotengine
I'm looking forward to speaking at PyCon Italia 2024, in Florence, Italy, later this week on Friday.
The title of the talk is "Advanced parsing of structured data using Python's new match statement". Given that the match statement still isn't used much in Python Land, I want to make people more aware of how useful it can be for parsing in Python.
It has shown me once more that although you’ll learn about cool #Python trends, ultimately it’s all about the people + the opportunity to connect F2F. 😍
Attend conferences! They are important for your career + ongoing inspiration💡 📈