r/Python • • Mar 24 '21

Discussion Python made me look like a WIZARD

Today in work a request comes in for 745 headshots that need to be processed to fit 150x150px for an external platform. One team says it'll take them at least a week to do, the other team says they don't want it as it'll take even longer.

"They need them all black and white! It'll take some time to convert them! They're not even all the same size! UGH this just can't be done in the 2 days they've requested this!!!"

12 lines of code, the Pillow library and exactly 8.856 seconds of running said code... It was done. Panic over. Client happy.

I work in a design team but I'm a job coordinator (so I sort the jobs and make sure the right designers get them). They were amazed it was done so quickly without using Photoshop.

They asked how. I gave them the answer.

Python baby 😎

EDIT

For those wanting to know the code, here it is:

from PIL import Image
import os

for f in os.listdir('Input'):
    if f.endswith('.jpg'):
        im = Image.new('RGB', (150, 150), (255,255,255))
        im2 = Image.open('Input/{}'.format(f))
        im2 = im2.convert("L")
        width, height = im2.size
        im.paste(im2, (int((150 - width) / 2), 0))
        fn, fext = os.path.splitext(f)
        im.save('Output/{}.jpg'.format(fn))

The images given were either 150x150 already (but in colour) or 120x150. So had to cover all bases with this. If it could be made more efficient, let me know!

2.2k Upvotes

278 comments sorted by

View all comments

Show parent comments

36

u/[deleted] Mar 24 '21

Shit, I work for a law firm too, it feels like a lot of them are complete technological backwaters. Peeps struggle to convert pdfs. I'm a tech wizard because I know how to paginate in Adobe.

11

u/[deleted] Mar 24 '21

Happens a lot, my old IT (before I switched teams) was helping us deploy dual monitors. 300 monitors were deployed and he plugged in a HDMI cable and a display cable from the docking station into 1 monitor. No word of a lie. I had to go round 150 desks and rectify the mistake. Another IT boss asked me how to attach a video from their iPhone to email. Baffled me how they were paid the big bucks!

10

u/[deleted] Mar 24 '21

Joke is that there are some places using neural networks to analyse legal document, and they're gonna run the dinosaurs out of business in the not too distant future.

Some judges are pretty bad too - I know of people that had to go into Court because the judge didn't know/was unwilling to learn how to do a remote hearing. In quarantine... during a pandemic... There was a clerk whose whole job was the get the judge a glass of water and bring lunch from the shop.

Thanks, stranger, I needed a good vent.

4

u/[deleted] Mar 24 '21

I wonder when we will see the first legal case defended by an AI

1

u/[deleted] Mar 24 '21

For a simple offence it may well be within the bounds of possiblity now, as long as you have a human flesh-puppet to say the actual words in court.

There's also this: https://www.theguardian.com/technology/2016/jun/28/chatbot-ai-lawyer-donotpay-parking-tickets-london-new-york