Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import base64
- import Image
- import os
- # image_list = [{filname:'...', anchor: {top, left}}, ...]
- def merge(image_list, output_file = None):
- if type(image_list) is not list:
- raise Exception('first argument is not a list')
- if len(image_list) < 2:
- raise Exception('image_list to short')
- if not output_file:
- filename_result = ''
- for image in image_list:
- filename_result += image['filename']
- filename_result = base64.encodestring(filename_result)
- filename_result += '.png'
- else:
- filename_result = output_file
- print(filename_result)
- if not os.path.isfile(filename_result):
- image_result = Image.open(image_list[0]['filename'])
- image_result.show()
- for image in image_list:
- image_result.paste(image['filename'], (image['anchor']['top'], \
- image['anchor']['top']), image['filename'])
- image_result.save(filename_result)
- return filename_result
- def sample():
- return [{'filename':'marker_base.png',
- 'anchor':{
- 'top':0,
- 'left':0
- }
- },
- {'filename':'overlay_education.png',
- 'anchor':{
- 'top':0,
- 'left':0
- }
- },]
Add Comment
Please, Sign In to add comment