Skip to content

Instantly share code, notes, and snippets.

@danielpaz6
Last active July 22, 2019 12:46
Show Gist options
  • Save danielpaz6/56a4bf455a8c79a5957c1fd1f393802d to your computer and use it in GitHub Desktop.
Save danielpaz6/56a4bf455a8c79a5957c1fd1f393802d to your computer and use it in GitHub Desktop.
When I started building my LinkedIn profile, I came upon a dilemma which background image to add. And I remember that for a long time I thought and looked for a background picture that would try to convey my message of creativity, rigor and passion for the world of programming and high-tech. And after a few days I came to the conclusion that the…

Linkedin Background Generator

When I started building my LinkedIn profile, I came upon a dilemma which background image to add. And I remember that for a long time I thought and looked for a background picture that would try to convey my message of creativity, rigor and passion for the world of programming and high-tech. And after a few days I came to the conclusion that the most correct and cool way I can think of is to create a program that will create a background image for me, a sort of canvas collage with random pixels in different colors and shapes. Inspired by the hypothetical images of github. And then I told myself that everyone should and can enjoy a picture of their own, so I decided to open a gist here in github.

Prerequisites

  • Python 3.6
  • Pillow ( PIL )
  • requests
import random
from PIL import Image, ImageEnhance
import requests
from io import BytesIO
width_count = 18;
height_count = 5;
offsetx = -5;
offsety = -5;
final_img = Image.new('RGB', (60*width_count + 2*offsetx, 60*height_count + 2*offsety))
print("Processing... ( may take a moment )");
for i in range(0, height_count):
for j in range(0, width_count):
while True: # do-while python-style
try:
response = requests.get("https://avatars2.githubusercontent.com/u/42693" + random.randint(100, 999).__str__());
img = Image.open(BytesIO(response.content));
rgb_im = img.convert('RGB');
r, g, b = rgb_im.getpixel((200, 419));
if((r,g,b) == (240, 240, 240)):
break;
except:
pass;
img = img.resize((60, 60), Image.ADAPTIVE);
enchancer = ImageEnhance.Brightness(img);
newimg = enchancer.enhance(1.1);
final_img.paste(newimg, (60 * j + offsetx, 60 * i + offsety));
final_img.save('output.png');
print("done.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment