I am trying to create some kind of screen share with python socket. The problem is that the images of my screen are very big (3,110,482 bytes) and it takes a lot of time for the socket to send them to the server. For making the sending more efficient I lowered the resolution of the images I am sending, but it is not enough. So I need to make the sending process more efficient.
Here is the function that takes images of my screen:
import numpy as np # for array manipulation
import pyautogui   # for recording images of the screen
import cv2         # for change the resolution of the images
from screeninfo import get_monitors # for getting the screen size
def get_screen_img(): # take an image of the screen and return it
    img = pyautogui.screenshot() # take a screenshot
    img = np.array(img) # convert to numpy array
    monitor = get_monitors()[0] # get info on the screen monitor
    # lowered the resolution by half
    img = cv2.resize(img, dsize=(monitor.width//2, monitor.height//2), interpolation=cv2.INTER_CUBIC)
    # do some manipulation for seeing the image right
    img = np.fliplr(img) # flip the image array
    img = np.rot90(img)  # rotate the image array in 90 degrees
    return img # return the image
Here is the function that sends the images:
import socket # for sending data
import pickle # for converting any kind of data to bytes
    def send_image(): # send a message
        # send the image and the type because I am sending more than just images so I need to tell the server what kind of info it gets
        msg = {"type": "image", "content": get_screen_img()}            
        msg = pickle.dumps(msg) # convert the message to bytes
    cSocket.send(msg) # send the msg
Edit: I am 99% sure that the problem is the size of the message. When I lowered the resolution more it works fine, but I need to send images in normal resolution.