def lonlat2px_gt(img, lon, lat, lon_min, lat_min, lon_max, lat_max):
    """
    Converts a pair of lon and lat to its corresponding pixel value in an
    geotiff image file.

    Parameters
    ----------
    img : Image File, e.g. PNG, TIFF
        Input image file
    lon : float
        Longitude
    lat : float
        Latitude
    lon_min, lat_min : float
        lower left coordinate of geotiff
    lon_max, lat_max : float
        upper right coordinate of geotiff

    Returns
    -------
    Row : float
        corresponding pixel value
    Col : float
        corresponding pixel value
    """

    w, h = img.size

    londiff = lon_max - lon_min
    latdiff = lat_max - lat_min

    mw = w / londiff
    mh = h / latdiff

    row = (-lat + lat_max) * mh
    col = (lon - lon_min) * mw

    return row, col