code: def extent_to_array(extent, source_crs, dest_crs=None):
      
  
      if dest_crs is None:
          geo_crs = QgsCoordinateReferenceSystem()
          geo_crs.createFromSrid(4326)
      else:
          geo_crs = dest_crs
  
      transform = QgsCoordinateTransform(source_crs, geo_crs,
                                         QgsProject.instance())
  
      # Get the clip area in the layer's crs
      transformed_extent = transform.transformBoundingBox(extent)
  
      geo_extent = [
          transformed_extent.xMinimum(),
          transformed_extent.yMinimum(),
          transformed_extent.xMaximum(),
          transformed_extent.yMaximum()]
      return geo_extent
docs: Convert the supplied extent to geographic and return as an array.
  
      :param extent: Rectangle defining a spatial extent in any CRS.
      :type extent: QgsRectangle
  
      :param source_crs: Coordinate system used for input extent.
      :type source_crs: QgsCoordinateReferenceSystem
  
      :param dest_crs: Coordinate system used for output extent. Defaults to
          EPSG:4326 if not specified.
      :type dest_crs: QgsCoordinateReferenceSystem
  
      :returns: a list in the form [xmin, ymin, xmax, ymax] where all
              coordinates provided are in Geographic / EPSG:4326.
      :rtype: list