Created
March 7, 2011 20:57
-
-
Save wwitzel3/859215 to your computer and use it in GitHub Desktop.
automatically scale and make thumbs of a featured image set in the yaml header.
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
try: | |
image = y['image'] | |
image_fd = os.path.join(bf.config.blog.media_path, image) | |
from PIL import Image | |
pImage = Image.open(image_fd) | |
image_path = image.split(os.sep) | |
image_name = image_path[-1] | |
pImage.thumbnail((320,320), Image.ANTIALIAS) | |
image_scale_fd = os.path.join(bf.config.blog.media_path, os.sep.join(image_path[0:-1]), 'scale.' + image_name) | |
pImage.save(image_scale_fd) | |
pImage.thumbnail((125,125), Image.ANTIALIAS) | |
image_thumb_fd = os.path.join(bf.config.blog.media_path, os.sep.join(image_path[0:-1]), 'thumb.' + image_name) | |
pImage.save(image_thumb_fd) | |
self.img_featured = os.path.join(bf.config.blog.media_url, os.sep.join(image_path[0:-1]), 'scale.' + image_name) | |
self.img_thumb = os.path.join(bf.config.blog.media_url, os.sep.join(image_path[0:-1]), 'thumb.' + image_name) | |
except KeyError: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment