<commit_before># -*- coding: utf-8 -*-

import PIL
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw

import sys

args_len = len(sys.argv)
if args_len == 1:
	# no args except the launch of the script
	print 'args plz'
elif args_len == 2:
	# only one argument, use standard meme
	topString = ''
	bottomString = sys.argv[-1].decode("utf-8").upper()
	meme = 'standard'
elif args_len == 3:
	# args give meme and one line
	topString = ''
	bottomString = sys.argv[-1].decode("utf-8").upper()
	meme = sys.argv[1].lower()
elif args_len == 4:
	# args give meme and two lines
	topString = sys.argv[-2].decode("utf-8").upper()
	bottomString = sys.argv[-1].decode("utf-8").upper()
	meme = sys.argv[1].lower()
else:
	# so many args
	# what do they mean
	# too intense
	print 'to many argz'

print meme

img = Image.open(str(meme)+'.jpg')
imageSize = img.size

# find biggest font size that works
fontSize = imageSize[1]/5
font = ImageFont.truetype("/Library/Fonts/Impact.ttf", fontSize)
topTextSize = font.getsize(topString)
bottomTextSize = font.getsize(bottomString)
while topTextSize[0] > imageSize[0]-20 or bottomTextSize[0] > imageSize[0]-20:
	fontSize = fontSize - 1
	font = ImageFont.truetype("/Library/Fonts/Impact.ttf", fontSize)
	topTextSize = font.getsize(topString)
	bottomTextSize = font.getsize(bottomString)

# find top centered position for top text
topTextPositionX = (imageSize[0]/2) - (topTextSize[0]/2)
topTextPositionY = 0
topTextPosition = (topTextPositionX, topTextPositionY)

# find bottom centered position for bottom text
bottomTextPositionX = (imageSize[0]/2) - (bottomTextSize[0]/2)
bottomTextPositionY = imageSize[1] - bottomTextSize[1]
bottomTextPosition = (bottomTextPositionX, bottomTextPositionY)

draw = ImageDraw.Draw(img)

# draw outlines
# there may be a better way
outlineRange = fontSize/15
for x in range(-outlineRange, outlineRange+1):
	for y in range(-outlineRange, outlineRange+1):
		draw.text((topTextPosition[0]+x, topTextPosition[1]+y), topString, (0,0,0), font=font)
		draw.text((bottomTextPosition[0]+x, bottomTextPosition[1]+y), bottomString, (0,0,0), font=font)

draw.text(topTextPosition, topString, (255,255,255), font=font)
draw.text(bottomTextPosition, bottomString, (255,255,255), font=font)

img.save("temp.png")<commit_msg>API-ification<commit_after># -*- coding: utf-8 -*-

import PIL
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw

import sys


def make_meme(topString, bottomString, filename):

	img = Image.open(filename)
	imageSize = img.size

	# find biggest font size that works
	fontSize = imageSize[1]/5
	font = ImageFont.truetype("/Library/Fonts/Impact.ttf", fontSize)
	topTextSize = font.getsize(topString)
	bottomTextSize = font.getsize(bottomString)
	while topTextSize[0] > imageSize[0]-20 or bottomTextSize[0] > imageSize[0]-20:
		fontSize = fontSize - 1
		font = ImageFont.truetype("/Library/Fonts/Impact.ttf", fontSize)
		topTextSize = font.getsize(topString)
		bottomTextSize = font.getsize(bottomString)

	# find top centered position for top text
	topTextPositionX = (imageSize[0]/2) - (topTextSize[0]/2)
	topTextPositionY = 0
	topTextPosition = (topTextPositionX, topTextPositionY)

	# find bottom centered position for bottom text
	bottomTextPositionX = (imageSize[0]/2) - (bottomTextSize[0]/2)
	bottomTextPositionY = imageSize[1] - bottomTextSize[1]
	bottomTextPosition = (bottomTextPositionX, bottomTextPositionY)

	draw = ImageDraw.Draw(img)

	# draw outlines
	# there may be a better way
	outlineRange = fontSize/15
	for x in range(-outlineRange, outlineRange+1):
		for y in range(-outlineRange, outlineRange+1):
			draw.text((topTextPosition[0]+x, topTextPosition[1]+y), topString, (0,0,0), font=font)
			draw.text((bottomTextPosition[0]+x, bottomTextPosition[1]+y), bottomString, (0,0,0), font=font)

	draw.text(topTextPosition, topString, (255,255,255), font=font)
	draw.text(bottomTextPosition, bottomString, (255,255,255), font=font)

	img.save("temp.png")


if __name__ == '__main__':

	args_len = len(sys.argv)
	if args_len == 1:
		# no args except the launch of the script
		print 'args plz'
	elif args_len == 2:
		# only one argument, use standard meme
		topString = ''
		bottomString = sys.argv[-1].decode("utf-8").upper()
		meme = 'standard'
	elif args_len == 3:
		# args give meme and one line
		topString = ''
		bottomString = sys.argv[-1].decode("utf-8").upper()
		meme = sys.argv[1].lower()
	elif args_len == 4:
		# args give meme and two lines
		topString = sys.argv[-2].decode("utf-8").upper()
		bottomString = sys.argv[-1].decode("utf-8").upper()
		meme = sys.argv[1].lower()
	else:
		# so many args
		# what do they mean
		# too intense
		print('to many argz')

	print meme	
	filename = str(meme)+'.jpg'
	make_meme(topString, bottomString, filename)	

{'fraction_non_alphanumeric': 0.1369519832985386, 'fraction_numerical': 0.02881002087682672, 'mean_word_length': 4.973815461346633, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2591761', 'n_tokens_mistral': 1765, 'n_tokens_neox': 1671, 'n_words': 412}