Created
January 14, 2013 11:11
-
-
Save mpcabd/4529367 to your computer and use it in GitHub Desktop.
Code for http://mpcabd.igeex.biz/get-pattern-from-an-image-in-pil-python/
Getting a pattern from an image in PIL (Python)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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