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

16

u/toyg Mar 24 '21

Well, demand for construction workers was definitely higher when they could only use shovels rather than excavators...

6

u/[deleted] Mar 24 '21

[removed] — view removed comment

12

u/[deleted] Mar 24 '21

But the total number of people employed is less, this is how efficiency happens. We are at a bad point in history where more and more tasks are being automated and fewer jobs are left for people. Add in that we look down our noses at most jobs that require people and allow those jobs to pay substandard wages. I love technology and the fact that a job like this can be automated with a few lines of code but lets look at it with eyes wide open.

8

u/[deleted] Mar 25 '21

[removed] — view removed comment

6

u/toyg Mar 25 '21

Employment numbers have become a political football in most countries, so they are often debatable in terms of reliability. The growth of the working poor is undoubtedly real though, with more and more people working even multiple jobs (and hence often double-counted in stats) but low-paid and unstable; that’s because they are employed at the margins of automated processes, doing things that are too difficult for robots but not difficult enough for a human to command a high wage. At the other end, we have the booming technocratic class (to which I myself belong), constantly reinventing the wheel in order to justify their jobs, but very likely to eventually be squeezed in numbers like specialized factory workers were squeezed once the wave of innovation slowed down in their sector.

Automation, in our current system, doesn’t serve people - it serves capital efficiency and profit. It’s undoubtedly an unstoppable force in the long run, but maybe we should think harder about how to get it to serve people instead.

5

u/[deleted] Mar 25 '21

This is a really common myth and misconception. It WAS true for awhile but is not holding true and getting worse at an increasing pace. We are at a tipping point. Unemployment is low because of the way unemployment is measured. Ronald Reagan changed the way unemployment is measured. Real unemployment is probably closer to 30%. Probably higher in some populations.

1

u/En-tro-py Mar 25 '21

It's a lack of imagination!

We're already short workers.

We can't find enough welders.

We spend the money to automate the majority of the job, now one welder can "supervise" the robots and do the actual difficult bits!

It's technically not hiring an equivalent number of welders, but also needs to be programmed, maintained, have quality control, planning, material handling from other roles...

Growth is a game of whack-a-mole.

2

u/[deleted] Mar 25 '21

This is complete bull. We are short in some areas and some welders, especially welders that are specialized in automated welding. Also 1 field being anecdotally short is not proof of what is going on in the entire system. It is absolutely true that technology is creating jobs as jobs are being eliminated. The issue is that 10 jobs are being eliminated as 2 or 3 are being created. Take the welding. Fewer old tech welders are needed because a robot can outweld 5 or 6 people. To make matters worse we don't have a way to retrain workers unless they pay for the retraining themselves in time and money. Unfortunately food, clothing, and shelter don't stop being necessities while people retrain. This makes it very difficult for people to retrain. Manufacturers in my area are crying for workers. The common refrain is "We can't find workers at any price" but the price they are offering is $12/hr - $13/hr. I ask them how someone is supposed to get from town and travel 5 -10miles to their factory? And there is no public transportation.

I was in a dark factory that makes plastic bottles you see on the shelves at wally world. The factory would have employed 100 people 20 years ago, today? 7 people. 7 people run the ENTIRE factory. Most of the place doesn't even have lights. Don't need them.

1

u/PepegaQuen Mar 26 '21

The issue is that 10 jobs are being eliminated as 2 or 3 are being created.

To do the same thing. But we're doing more things.

→ More replies (0)