Resize_image(input_image_path, output_image_path, max_size) Max_size = 500 # Desired max size for width or height Input_image_path = "path/to/your/original/image.jpg" Resized_image = image.resize((new_width, new_height), Image.ANTIALIAS) New_width = int(new_height * aspect_ratio) New_height = int(new_width / aspect_ratio) Original_width, original_height = image.sizeĪspect_ratio = float(original_width) / float(original_height) Then, use the following code to resize an image while maintaining its aspect ratio:ĭef resize_image(input_image_path, output_image_path, max_size):. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |