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

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.

0

u/[deleted] Mar 24 '21

[deleted]

5

u/[deleted] Mar 24 '21

Oh, no arguement from me. I don't know where this is all headed.

5

u/toyg Mar 25 '21

I don’t disagree. Still a problem though.

0

u/[deleted] Mar 25 '21

[deleted]

3

u/toyg Mar 25 '21

I think it’s both. There is currently little or no incentive to develop automation for processes that don’t serve capital investment. Our social networks serve advertising, our inventory systems serve giant distribution chains, our job-management systems serve tax-skirting taxi owners... almost none of them actually serve human processes where profit is not present or there isn’t an incentive to reduce costs. We need better automation to build better communities and better lives, and that needs to be incentivised somehow.

So we need to think about how we redistribute the profits automation generates, but also how we get automation to help things that don’t immediately generate money.

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.

1

u/Rugged_M Mar 25 '21

Slightly disagree here, how many new industries have been created due to these efficiency increases. Look at tech, things are being more and more automated but they need to hire more and more programmers to keep up with the new innovations or industries that come out of it.

Those innovations need more designers, creators, photographers, who need more cameras, new accessories, lenses, who need new designers, who use new software, who need to be managed by new software, and all those things need machines or computers to make which in turn employs factory workers, miners, who also need tools, software, equipment from other suppliers etc....

We are creating new industries at a breakneck pace.

1

u/[deleted] Mar 25 '21

d i

Yes we are. And eliminating more jobs than we are creating in the process. I am not arguing the fact that technology creates jobs. This is 100% true. What I am saying is that there are more jobs eliminated than are created.

1

u/PepegaQuen Mar 26 '21

But the total number of people employed is less, this is how efficiency happens.

Or we're able to build more. Or better than before.