Does the PIL change the exact dimensions that I give them, no matter what? Or will he try to keep the aspect ratio if I give him something like the Image.ANTIALIAS argument?
Image.ANTIALIAS
How to resize an image using PIL and keep its aspect ratio?
Image.resize from PIL will do exactly the same as said. Not behind the scenes.
Yes, it will keep proportions using the sketch method:
image = Image.open(source_path) image.thumbnail(size, Image.ANTIALIAS) image.save(dest_path, "JPEG")
Yes. The thumbnail () method is what is needed here ... One thing that was not mentioned in this or other related posts is that the "size" must be either a list or a tuple. Thus, to resize to a maximum size of 500 pixels, you would call: image.thumbnail ((500 500), Image.ANTIALIAS)
See also this entry on this topic: How do I resize an image using PIL and keep its aspect ratio?
Source: https://habr.com/ru/post/1300814/More articles:Query works fine in phpmyadmin returns 0 lines when launched with php - phpFilling a DropDownList based on another DropDownList (Cascading Drop Down) - c #Android Database Backup - androidmysql query works manually, but returns no results when run from code - phpMoving checkmarks in checkboxes after page reload - Firefox only - jqueryIs there a difference between the two affirmations? Belong? - ruby | fooobar.comWill Core Data create a persistent storage file for me? - iphoneUsing maven to manage java dependencies in jruby rails application - maven-2Running eclipse on Tomcat - Debug mode - Timeout error - debuggingMechanize not recognize anchor labels using CSS selector methods - cssAll Articles