Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Code for http://mpcabd.igeex.biz/get-pattern-from-an-image-in-pil-python/ Getting a pattern from an image in PIL (Python)
def get_pattern_from_image(file_name, pattern_width, pattern_height):
import Image
pattern_image = Image.open(file_name, 'r')
result_image = Image.new('RGB', (pattern_width, pattern_height))
x = 0
while x < pattern_width:
y = 0
while y < pattern_height:
result_image.paste(pattern_image, (x, y))
y += pattern_image.size[1]
x += pattern_image.size[0]
return result_image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment