Update image_display.py
Browse files- image_display.py +7 -4
image_display.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
from PIL import Image
|
| 2 |
|
| 3 |
-
def display_side_by_side(image1_path, image2_path):
|
| 4 |
# Open images using Pillow
|
| 5 |
image1 = Image.open(image1_path)
|
| 6 |
image2 = Image.open(image2_path)
|
|
@@ -22,11 +22,14 @@ def display_side_by_side(image1_path, image2_path):
|
|
| 22 |
side_by_side.paste(image1, (0, 0))
|
| 23 |
side_by_side.paste(image2, (width, 0))
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
side_by_side.
|
| 27 |
|
| 28 |
# Example usage:
|
| 29 |
if __name__ == "__main__":
|
| 30 |
image1_path = 'path_to_image1.jpg'
|
| 31 |
image2_path = 'path_to_image2.jpg'
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from PIL import Image
|
| 2 |
|
| 3 |
+
def display_side_by_side(image1_path, image2_path, output_path):
|
| 4 |
# Open images using Pillow
|
| 5 |
image1 = Image.open(image1_path)
|
| 6 |
image2 = Image.open(image2_path)
|
|
|
|
| 22 |
side_by_side.paste(image1, (0, 0))
|
| 23 |
side_by_side.paste(image2, (width, 0))
|
| 24 |
|
| 25 |
+
# Save the side by side image to a file
|
| 26 |
+
side_by_side.save(output_path)
|
| 27 |
|
| 28 |
# Example usage:
|
| 29 |
if __name__ == "__main__":
|
| 30 |
image1_path = 'path_to_image1.jpg'
|
| 31 |
image2_path = 'path_to_image2.jpg'
|
| 32 |
+
output_path = 'side_by_side.jpg'
|
| 33 |
+
display_side_by_side(image1_path, image2_path, output_path)
|
| 34 |
+
|
| 35 |
+
print(f"Images displayed side by side and saved as {output_path}")
|