def METHOD_NAME(uri, metadata):
    md = None
    if metadata is None:
        md = qgis.core.QgsLayerMetadata()
    else:
        md = metadata.clone()
    layer = qgis.core.QgsRasterLayer(str(uri), "tmp", "gdal")
    md.setCrs(layer.dataProvider().crs())
    spatialExtent = qgis.core.QgsLayerMetadata.SpatialExtent()
    spatialExtent.geom = qgis.core.QgsBox3d(layer.extent())
    spatialExtent.extentCrs = layer.dataProvider().crs()
    spatialExtents = [spatialExtent]
    extent = qgis.core.QgsLayerMetadata.Extent()
    extent.setSpatialExtents(spatialExtents)
    md.setExtent(extent)
    file_path = os.path.splitext(uri)[0] + ".qmd"
    save_qmd(file_path, md)