Image
¶
- class mwclient.image.Image(site, name, info=None)[source]¶
Represents an image on a MediaWiki wiki represented by a
Site
object.- Parameters:
site (mwclient.client.Site) – The site object this page belongs to.
name (Union[str, int, Page]) – The title of the page, the page ID, or another
Page
object to copy.info (Optional[dict]) – Page info, if already fetched, e.g., when iterating over a list of pages. If not provided, the page info will be fetched from the API.
- download() bytes [source]¶
- download(destination: BufferedWriter) None
Download the file. If destination is given, the file will be written directly to the stream. Otherwise the file content will be stored in memory and returned (with the risk of running out of memory for large files).
Recommended usage:
>>> with open(filename, 'wb') as fd: ... image.download(fd)
- Parameters:
destination – Destination file
- duplicatefiles(limit=None, max_items=None, api_chunk_size=None)[source]¶
List duplicates of the current file.
API doc: https://www.mediawiki.org/wiki/API:Duplicatefiles
limit sets a hard cap on the total number of results, it does not only specify the API chunk size.
- Parameters:
limit (int | None)
max_items (int | None)
api_chunk_size (int | None)
- Return type:
PageProperty
- imagehistory()[source]¶
Get file revision info for the given file.
API doc: https://www.mediawiki.org/wiki/API:Imageinfo
- Return type:
PageProperty
- imageusage(namespace=None, filterredir='all', redirect=False, limit=None, generator=True, max_items=None, api_chunk_size=None)[source]¶
List pages that use the given file.
API doc: https://www.mediawiki.org/wiki/API:Imageusage
- Parameters:
namespace (str | int | None)
filterredir (str)
redirect (bool)
limit (int | None)
generator (bool)
max_items (int | None)
api_chunk_size (int | None)
- Return type:
List