logo_image
logo_image(
team: Any,
league: str,
*,
season: Any = None,
variant: str = 'default',
mark_type: Literal['logo', 'wordmark'] = 'logo',
size: int | None = None,
id_system: Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] = 'auto',
strict: bool = False,
) -> PIL.Image.Image | None
The team's mark as a PIL image (downloaded once, then cached).
Arguments
| Name | Type | Description |
|---|---|---|
team | Any | One team identifier (abbreviation, name, ESPN id, ...). |
league | str | The SDV league key, e.g. "nfl". |
season | Any | A season year; None picks the current mark. |
variant | str | "default", "dark", or a named variant from marks(). |
mark_type | Literal['logo', 'wordmark'] | "logo" or "wordmark". |
size | int | None | The longest side in pixels, an int from 1 to 4096. Rasters are only scaled down; SVGs are rasterized at it (default 512). Without it a raster comes at the archive's size, up to 4096 px (64 MiB decoded): pass size when the image is for a plot. |
id_system | Literal['auto', 'team_id', 'espn', 'espn_abbr', 'nhl', 'nflverse', 'mlbstats', 'nba_api', 'hockeytech', 'ncaa', 'pff', 'cricinfo', 'cfbd', 'bref', 'sportsipy', 'fangraphs', 'sdvplotr', 'name', 'nhl_id'] | The id system of team, as in resolve: "auto" tries each in order; NHL stats ids need "nhl_id". |
strict | bool | Raise UnresolvedTeamError instead of warning when the team does not resolve. |
Returns
PIL.Image.Image | None: The image, or None when the team does not resolve or has no mark.
Raises
TypeError: Ifteamis not a single value.OptionalDependencyError: If the mark is an SVG and thesvgextra is not installed.OfflineError: If the download fails and no cached copy exists.DownloadError: (an OfflineError and an OSError) If the CDN answers with an error status (a 4xx or 5xx response) and no cached copy exists.IntegrityError: (a DownloadError) If the download does not match the manifest's sha256, or is not an image PIL can decode.UnsafeDownloadError: (an OSError) If the download is refused: larger than the byte cap, past the deadline, or redirected away from https.UnsafeCachePathError: (a ValueError) If the manifest's sha256 or extension for the mark would put the file outside the cache directory.InputError: (a ValueError) Ifleagueorid_systemis unknown,mark_typeis not "logo"/"wordmark",variantis a name no mark in the archive has,seasonis not a year or is outside the seasons sdvplot knows for the league, orsizeis not an int from 1 to 4096.UnresolvedTeamError: (a ValueError) Ifstrict=Trueand the team does not resolve.ValueError: If an SVG cannot be parsed; anInputErrorif it is more than 64 times longer than it is wide.
Example
import sdvplot
img = sdvplot.logo_image("KC", "nfl", size=64)
img.size # (64, 64)