geemap/geemap.py
def image_overlay(self, url, bounds, name):
        """Overlays an image from the Internet or locally on the map.

        Args:
            url (str): http URL or local file path to the image.
            bounds (tuple): bounding box of the image in the format of (lower_left(lat, lon), upper_right(lat, lon)), such as ((13, -130), (32, -100)).
            name (str): name of the layer to show on the layer control.
        """
        from base64 import b64encode
        from io import BytesIO

        from PIL import Image, ImageSequence

        try:
            if not url.startswith("http"):

                if not os.path.exists(url):
                    print("The provided file does not exist.")
                    return

                ext = os.path.splitext(url)[1][1:]  # file extension
                image = Image.open(url)

                f = BytesIO()
                if ext.lower() == "gif":
                    frames = []
                    # Loop over each frame in the animated image
                    for frame in ImageSequence.Iterator(image):
                        frame = frame.convert("RGBA")
                        b = BytesIO()
                        frame.save(b, format="gif")
                        frame = Image.open(b)
                        frames.append(frame)
                    frames[0].save(
                        f,
                        format="GIF",
                        save_all=True,
                        append_images=frames[1:],
                        loop=0,
                    )
                else:
                    image.save(f, ext)

                data = b64encode(f.getvalue())
                data = data.decode("ascii")
                url = "data:image/{};base64,".format(ext) + data
            img = ipyleaflet.ImageOverlay(url=url, bounds=bounds, name=name)
            self.add_layer(img)
        except Exception as e:
            print(e)
Overlays an image from the Internet or locally on the map.

        Args:
            url (str): http URL or local file path to the image.
            bounds (tuple): bounding box of the image in the format of (lower_left(lat, lon), upper_right(lat, lon)), such as ((13, -130), (32, -100)).
            name (str): name of the layer to show on the layer control.
        
Overlays an image from the Internet or locally on the map.
Overlays an image from the Internet or locally on the map .
def image_overlay(self, url, bounds, name):
        from base64 import b64encode
        from io import BytesIO
        from PIL import Image, ImageSequence
        try:
            if not url.startswith("http"):
                if not os.path.exists(url):
                    print("The provided file does not exist.")
                    return
                ext = os.path.splitext(url)[1][1:]  
                image = Image.open(url)
                f = BytesIO()
                if ext.lower() == "gif":
                    frames = []
                    for frame in ImageSequence.Iterator(image):
                        frame = frame.convert("RGBA")
                        b = BytesIO()
                        frame.save(b, format="gif")
                        frame = Image.open(b)
                        frames.append(frame)
                    frames[0].save(
                        f,
                        format="GIF",
                        save_all=True,
                        append_images=frames[1:],
                        loop=0,
                    )
                else:
                    image.save(f, ext)
                data = b64encode(f.getvalue())
                data = data.decode("ascii")
                url = "data:image/{};base64,".format(ext) + data
            img = ipyleaflet.ImageOverlay(url=url, bounds=bounds, name=name)
            self.add_layer(img)
        except Exception as e:
            print(e)
def image_overlay ( self , url , bounds , name ) : from base64 import b64encode from io import BytesIO from PIL import Image , ImageSequence try : if not url . startswith ( "http" ) : if not os . path . exists ( url ) : print ( "The provided file does not exist." ) return ext = os . path . splitext ( url ) [ 1 ] [ 1 : ] image = Image . open ( url ) f = BytesIO ( ) if ext . lower ( ) == "gif" : frames = [ ] for frame in ImageSequence . Iterator ( image ) : frame = frame . convert ( "RGBA" ) b = BytesIO ( ) frame . save ( b , format = "gif" ) frame = Image . open ( b ) frames . append ( frame ) frames [ 0 ] . save ( f , format = "GIF" , save_all = True , append_images = frames [ 1 : ] , loop = 0 , ) else : image . save ( f , ext ) data = b64encode ( f . getvalue ( ) ) data = data . decode ( "ascii" ) url = "data:image/{};base64," . format ( ext ) + data img = ipyleaflet . ImageOverlay ( url = url , bounds = bounds , name = name ) self . add_layer ( img ) except Exception as e : print ( e )
Overlays an image from the Internet or locally on the map.
Overlays an image from the Internet or locally on the map .
"""Overlays an image from the Internet or locally on the map.

        Args:
            url (str): http URL or local file path to the image.
            bounds (tuple): bounding box of the image in the format of (lower_left(lat, lon), upper_right(lat, lon)), such as ((13, -130), (32, -100)).
            name (str): name of the layer to show on the layer control.
        """ # file extension
 # Loop over each frame in the animated image

self
url
http URL or local file path to the image.
http URL or local file path to the image .
bounds
bounding box of the image in the format of (lower_left(lat, lon), upper_right(lat, lon)), such as ((13, -130), (32, -100)).
bounding box of the image in the format of ( lower_left ( lat lon ) upper_right ( lat lon )) such as (( 13 - 130 ) ( 32 - 100 )) .
name
name of the layer to show on the layer control.
name of the layer to show on the layer control .