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

296

u/[deleted] Mar 24 '21

they don't really like automation that much - they fear it will put them out of work! But I guess they'll have embrace it for the mundane jobs like this

334

u/cbunn81 Mar 24 '21 edited Mar 24 '21

Better they do the automation themselves rather than wait around for clients to leave for another company that uses automation.

44

u/[deleted] Mar 24 '21

Code for designers!

14

u/sewerinspector Mar 24 '21

Fantastic username, el guapo

11

u/[deleted] Mar 24 '21

8

u/fruitcup729again Mar 24 '21

Would you say I have a plethora of pinatas?

→ More replies (1)

9

u/XecutionerNJ Mar 25 '21

Yeah, Apple made the iPhone because the nokia and sony Ericsson phones were getting to be really good ipods and would destroy apples product line.

When others are innovating you out of work, you have to get on the innovation side and kick yourself out of work. Either that or wait for obsolescence.

11

u/cbunn81 Mar 25 '21

Steve Jobs himself said that if you don't cannibalize your own business, someone else will. I remember reading about that when the iPad came out, because apparently done within Apple were worried that it would cannibalize their laptop sales. Well, sure, but you also broaden your consumer base, so it's a net positive. And it would only be a matter of time before another company made a popular tablet, anyway. Then you'd have to play catch up.

→ More replies (1)
→ More replies (1)
→ More replies (2)

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.

→ More replies (7)

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.

→ More replies (3)

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.

→ More replies (5)
→ 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.

→ More replies (1)

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.

→ More replies (4)

40

u/beisenhauer Mar 24 '21

Automate the boring stuff, amiright?

→ More replies (1)

42

u/d64 Mar 24 '21

You know how consulting companies that have done some kind of a job many times before will bill a customer say 40 hours for doing it, even though it might take them only 6 hours to do, because of their expertise?

Employees can and should do the same. Say this job was said to take days. Tell you will do it, then write the script or use Photoshop batches or whatever, be done in 45 minutes. Then spend the rest of the day on your own projects, then report triumphantly that you managed to pull it off in just one day. You are seen as efficient, but you are not shooting yourself in the foot by revealing the job can actually be done in no time at all.

22

u/[deleted] Mar 24 '21

It's not my main job - I'm a job coordinator so I handle the requests for work. I just program on the side for fun and wanted to help out. I guess I need to be careful it doesn't open a door for them to request more of this and I land myself in a hole!

7

u/sodjanathan Mar 24 '21

The kind of hole that brought me so many sql reports requests at work with no extra pay

→ More replies (4)
→ More replies (6)