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

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.

1

u/[deleted] Mar 26 '21

But we aren't. That is just a cold hard fact. In the late 19th and 20th century we automated much of the manual labor. That work went away. We did get lucky in that many of those workers transitioned to factory work and were employed. We are now automating much of the intellectual work that was traditionally done by educated people. This work can also move at a moment's notice across the globe. The special effects business is a really good example. That work has been going to India, Thailand, China, or wherever the movie industry can find the cheapest labor. It has also required fewer people to do the same work. We are automating work faster than new jobs can be created. I am not arguing these facts to be a Luddite or pedantic. It is extremely important that we all understand this about the new new economy. We can't allow this to continue using economic principles of what work is and isn't created over 100 years ago. We are taxing the wrong things and the wrong people. If we understand at the core that people are being phased out and priced out of work, it only stands to reason that we start looking to where the productivity is happening to where taxes need to be targeted. I don't care what your position is on small government as long as we can agree that government needs to exist and has responsibilities to society like infrastructure, civic protection, law and code enforcement, etc. We can quible over the level but the money to support those tasks have to come from somewhere. We are in a system that is starving the bottom and there is gluttony at the top. As long as people believe that there are good opportunities at the bottom, people just have to look, and that there are more opportunities than are there, we have a problem. We need to offer universal and free healthcare that is NOT tied to employment as well as free training for people to change and upgrade work skills. We also need to raise the wages for people doing the jobs robots just can't do. I have never understood why a middle manager can make $100k a year and can be automated but the custodian makes $20k and his job can't.