Combine 2 Images to Form a Single Image

Abhay desai
3 min readJun 6, 2021

Step 1: Install cv2 Module.

command : pip install opencv-python.

|| OpenCV (Open Source Computer Vision Library) is a library of programming functions mainly aimed at real-time computer vision. ||

Step 2: Import cv2 and Numpy

Importing cv2 module and Importing numpy

Importing cv2 and numpy

Step 3 : Lets Read and Display the Particular Image.


cv2.imread (‘image’) #reading the image

cv2.imshow(window_name, image) #display image
cv2.waitkey(time in ms) # wait for a specific time in milliseconds
cv2.destroyAllWindows() # destroy the window after displaying the image

Image 1 :


Image 2 :

#Same Syntax

#For Reading and Display the Image.


Step 4 : Lets Check The size of our Image

#syntax : variablename.shape

Step 5 : Crop or Resize the Photo

We will Crop or Resize the photo1 in the same shape of Photo2 to get an Proper Output with the Same Size in Height and Width.

Step 6: Attach The Image Horizontally.

we will attach both the image photo1_res and photo2 horizontally by using Numpy.

#numpy.hstack((image1 ,image2))

EX: we can see as the image in the form Collage

Step 7: Output:


Hope you Find It Intresting..!!

Thank you..!!