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

0

u/[deleted] Mar 24 '21

[deleted]

56

u/bailey25u Mar 24 '21

My supervisor is at that point right now all the time. I automated most of our job while he was out for 3 weeks. When he got back and saw me doing a lot of extra tasks for other teams, he freaked out. When I showed him how much of our job is now automated, he tried to undo everything I did. Fortunately, I showed our manager who said we had to keep those processes in place

19

u/analytix_guru Mar 24 '21

I am saddened when I read posts/comments like this. What is the mental state of someone that feels it is better to be inefficient at their job, for "job security"? There might be something more important or valuable to work on if the mundane tasks would be removed. Maybe that person won't get found out for weeks/months/years, but when the easier, more efficient method is found, change usually occurs, and does not usually benefit the one who remained inefficient.

From experience and the variety of jobs I have had in my career, I have never run into a problem where the was no more work if I made something more efficient or automated than it was before. And there were almost always accolades, incentive$, or promotions to go along with it.

12

u/fuzzylumpkinsbc Mar 24 '21

I can try to see both sides, the manager might fear that the employee that automated these tasks left and there would be no one to maintain it. In that particular case it could do more harm than good.

But of course, being proactive and asking the person to put documentation together would help keep things safe.

12

u/Cand_PjuskeBusk Mar 24 '21

What is the mental state of someone that feels it is better to be inefficient at their job, for "job security"?

Are you serious? If someone believes that less efficiency will make sure he and other employees will remain employed for longer, it's not exactly hard to imagine he'll fight to make sure it stays that way.

You must be in an incredibly priviledged position to believe MAXIMUM EFFICIENCY is more important than having a job to pay the bills.

14

u/analytix_guru Mar 24 '21 edited Mar 25 '21

I spent most of my career in very much not privileged, low paying positions. What got me to the privileged position I am working in today was being more efficient, effective and valuable than the other people I was working with.

Just had a project at work where we automated an analytics pipeline that will save enough hours for a full time person. What are we doing? Not firing anyone, rather using that freed up time to do more valuable work.

Being that I have a background in economics, and am kinda a behavioral economics nerd, I am not surprised at all that people act like this to preserve their well being. I am also not naive to think that people have never been fired for a task/role being optimized. But in most cases people are usually given a new problem or task to work on

7

u/En-tro-py Mar 25 '21

This type of attitude is cancer in an organization.

I went into engineering because I am lazy... Lazy enough to only want to solve a problem once!

Any process we're automating is displacing a worker, however our current growth is also faster than we're able to fill all the openings.

Gold bricking is a toxic drain and if you're not fighting against it your group will be sucked into a cesspool of mediocrity.

3

u/analytix_guru Mar 25 '21

I like that line, never heard it before, lazy enough to only want to solve a problem once. Will keep that one in my back pocket.

Also fist time I had hear the term gold bricking used. Had to look it up!

→ More replies (1)

7

u/The_Drinkist Mar 25 '21

What u/analytix_guru said. In my field, if we can automate and redeploy people to more productive tasks, maybe we have 20+ years of employment. If we don’t, it’s a couple of years before clients start to migrate to firms that did. And not many people are hiring from dinosaur firms, so pay my bills for the long term and have more interesting work or save my current job for 2 years and then go homeless. Easy choice if your head is not anatomically misplaced.

→ More replies (1)

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.

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.

→ More replies (4)
→ More replies (3)

9

u/Gorstag Mar 24 '21

About a year ago I got laid off work due to myself and my colleague making our department significantly more efficient (Over many years). Around the same total revenue but about half the incoming workload. So they basically cut our staff in half at all levels and I got the axe. The departments that were an absolute clusterfuck due to mismanagement and other reasons... no cuts at all.

So I do get the sentiment also, because ultimately being too efficient can end up working you out of a job.

5

u/justasapling Mar 24 '21

I get this mentality but it's also so frustrating. At what point do people just start choosing the least efficient method possible to do things?

When you're treated as a resource rather than an asset you have no incentive to do anything well.

People will be free to do their work as well as possible only when 'security' is complete. Not job security, but rather livelihood security.

5

u/blahblah98 Mar 24 '21

Actually a tactic in countries seeking to keep the masses gainfully employed: China, India, Pakistan, Indonesia, Brazil, parts of Africa, etc.

But you're right, we ought to have innovation w/o exploitation: automation, creative gainful employment and increasing 1st world standards of living, probably requiring some combo of UBI & robot/automation tax...

→ More replies (2)