Last active
April 10, 2016 17:39
-
-
Save dogancankilment/18e9bc2c908a38106059b63232378fd6 to your computer and use it in GitHub Desktop.
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
import os | |
import PIL | |
from PIL import Image | |
def image_resizer(path): | |
img = Image.open(path) | |
basewidth = 700 | |
wpercent = (basewidth / float(img.size[0])) | |
# hsize = int((float(img.size[1]) * float(wpercent))) | |
hsize = 300 | |
img = img.resize((basewidth, hsize), PIL.Image.ANTIALIAS) | |
img.save(path) | |
if __name__ == '__main__': | |
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) | |
image_path = os.path.join(BASE_DIR, 'your-image.jpeg') | |
image_resizer(image_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment