One of the very useful modules for imaging is PIL ...
# explore the Python Image Library (PIL)
# download PIL from:
# http://www.pythonware.com/products/pil/
from PIL import Image
# pick an image file you have in the working directory
# (or give full path name)
image_file = "french_flag.bmp"
img = Image.open(image_file)
# get the image's width and height in pixels
width, height = img.size
vegaseat
DaniWeb's Hypocrite
6,476 posts since Oct 2004
Reputation Points: 1,447
Solved Threads: 1,612
Skill Endorsements: 36
Something as simple as this might do ...
# explore resizing with the Python Image Library (PIL)
# download PIL from: http://www.pythonware.com/products/pil/
from PIL import Image
# pick an image file you have in the working directory
# (or give full path name)
image_file = "french_flag.bmp"
img = Image.open(image_file)
# get the image's width and height in pixels
width, height = img.size
# get the largest dimension
max_dim = max(img.size)
# resize the image using the largest side as dimension
factor = 0.7
side = int(max_dim*factor)
resized_image = img.resize((side, side), Image.ANTIALIAS)
# save the resized image to a file
# and view it with your favorite image viewer
resized_image_file = "aa_image.jpg"
resized_image.save(resized_image_file)
# inform the user
print("%s saved!" % resized_image_file)
vegaseat
DaniWeb's Hypocrite
6,476 posts since Oct 2004
Reputation Points: 1,447
Solved Threads: 1,612
Skill Endorsements: 36
That won't keep proportions.
Hard to figure out if the OP wanted to maintain proportions from the question. You are a better mind reader!
vegaseat
DaniWeb's Hypocrite
6,476 posts since Oct 2004
Reputation Points: 1,447
Solved Threads: 1,612
Skill Endorsements: 36
Beat_Slayer take it easy, you are simply harsh on yourself! On some of the questions asked here, you have to be a mind reader. I simply gave you credit for that. I didn't mean to offend you in any way!
vegaseat
DaniWeb's Hypocrite
6,476 posts since Oct 2004
Reputation Points: 1,447
Solved Threads: 1,612
Skill Endorsements: 36
I'm sorry if you take it personnaly vegaseat, I really didn't mean it.
I just see lost of my posts harshly commented, and decided to let it out, only that.
Congrats
I know I posted 'against' your MasterMind solution but that was because it was buggy. If your solution works according to specks I will not critisize but give maybe my alternative way, if I see somebody could like it.
Don't take offense from me, bear with my terrible grammar, learn to be appreciative of bugs and debugging as best way to learn and as thex say in Asia: Thank xou for your hard work! Cheers, man!
pyTony
pyMod
6,310 posts since Apr 2010
Reputation Points: 879
Solved Threads: 987
Skill Endorsements: 26
Question Answered as of 2 Years Ago by
Beat_Slayer,
vegaseat,
snippsat
and 1 other