Skip to content

Commit

Permalink
Merge pull request #96 from The-MoonTg-project/deepsource-autofix-4c1…
Browse files Browse the repository at this point in the history
…4708c

refactor: remove unnecessary whitespace
  • Loading branch information
AbhiTheModder authored Aug 8, 2024
2 parents 272ce31 + 17f5f1a commit 2c144b2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions utils/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,28 +376,28 @@ def resize_image(
def resize_new_image(image_path, output_path, desired_width=None, desired_height=None):
"""
Resize an image to the desired dimensions while maintaining the aspect ratio.
Args:
image_path (str): Path to the input image file.
output_path (str): Path to save the resized image.
desired_width (int, optional): Desired width in pixels. If not provided, the aspect ratio will be maintained.
desired_height (int, optional): Desired height in pixels. If not provided, the aspect ratio will be maintained.
"""
image = Image.open(image_path)

width, height = image.size

aspect_ratio = width / height

if desired_width and desired_height:
new_width, new_height = desired_width, desired_height
elif desired_height:
new_width, new_height = int(desired_height * aspect_ratio), desired_height
else:
new_width, new_height = 150, 150

resized_image = image.resize((new_width, new_height), Image.Resampling.LANCZOS)

resized_image.save(output_path)
if os.path.exists(image_path):
os.remove(image_path)
Expand Down

0 comments on commit 2c144b2

Please sign in to comment.