Skip to content

Commit bb0ad2a

Browse files
authored
Merge pull request #811 from Harshak30/image_collage
Image Collage
2 parents 3dbb6b6 + 346a87f commit bb0ad2a

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

image_collage/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# IMAGE COLLAGE
2+
A python script which is used to make 2X2 image collage and the final image can be saved in the system.
3+
4+
## INPUT
5+
It takes four image url's as an input.
6+
7+
## OUTPUT
8+
It saves the image collage to the specified path.

image_collage/image_collage.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import requests
2+
from PIL import Image
3+
from io import BytesIO
4+
import numpy as np
5+
6+
lst = []
7+
for i in range(0, 4):
8+
url = input("Enter your image URL:")
9+
try:
10+
res = requests.get(url)
11+
except Exception:
12+
print("Can't access the URL")
13+
continue
14+
img = Image.open(BytesIO(res.content))
15+
new_image = img.resize((200, 200))
16+
lst.append(new_image)
17+
image1 = np.array(lst[0])
18+
image2 = np.array(lst[1])
19+
image3 = np.array(lst[2])
20+
image4 = np.array(lst[3])
21+
final = np.vstack([np.hstack([image1, image2]), np.hstack([image3, image4])])
22+
collageimage = Image.fromarray(final)
23+
collageimage.save("D:/Imagecollage.jpg")
24+
print("Image saved in the given path")

image_collage/requirements.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
numpy
2+
requests
3+
pillow
4+
BytesIO

0 commit comments

Comments
 (0)