MCPcopy
hub / github.com/matplotlib/matplotlib / thumbnail

Function thumbnail

lib/matplotlib/image.py:1791–1853  ·  view source on GitHub ↗

Make a thumbnail of image in *infile* with output filename *thumbfile*. See `Pillow for a replacement `_. Parameters ---------- infile : str or file-like The image file. Matplotl

(infile, thumbfile, scale=0.1, interpolation='bilinear',
              preview=False)

Source from the content-addressed store, hash-verified

1789
1790@_api.deprecated('3.11', alternative="Pillow's `PIL.Image.Image.thumbnail`")
1791def thumbnail(infile, thumbfile, scale=0.1, interpolation='bilinear',
1792 preview=False):
1793 """
1794 Make a thumbnail of image in *infile* with output filename *thumbfile*.
1795
1796 See `Pillow for a replacement
1797 <https://pillow.readthedocs.io/en/stable/handbook/tutorial.html#create-jpeg-thumbnails>`_.
1798
1799 Parameters
1800 ----------
1801 infile : str or file-like
1802 The image file. Matplotlib relies on Pillow_ for image reading, and
1803 thus supports a wide range of file formats, including PNG, JPG, TIFF
1804 and others.
1805
1806 .. _Pillow: https://python-pillow.github.io
1807
1808 thumbfile : str or file-like
1809 The thumbnail filename.
1810
1811 scale : float, default: 0.1
1812 The scale factor for the thumbnail.
1813
1814 interpolation : str, default: 'bilinear'
1815 The interpolation scheme used in the resampling. See the
1816 *interpolation* parameter of `~.Axes.imshow` for possible values.
1817
1818 preview : bool, default: False
1819 If True, the default backend (presumably a user interface
1820 backend) will be used which will cause a figure to be raised if
1821 `~matplotlib.pyplot.show` is called. If it is False, the figure is
1822 created using `.FigureCanvasBase` and the drawing backend is selected
1823 as `.Figure.savefig` would normally do.
1824
1825 Returns
1826 -------
1827 `.Figure`
1828 The figure instance containing the thumbnail.
1829 """
1830
1831 im = imread(infile)
1832 rows, cols, depth = im.shape
1833
1834 # This doesn't really matter (it cancels in the end) but the API needs it.
1835 dpi = 100
1836
1837 height = rows / dpi * scale
1838 width = cols / dpi * scale
1839
1840 if preview:
1841 # Let the UI backend do everything.
1842 import matplotlib.pyplot as plt
1843 fig = plt.figure(figsize=(width, height), dpi=dpi)
1844 else:
1845 from matplotlib.figure import Figure
1846 fig = Figure(figsize=(width, height), dpi=dpi)
1847 FigureCanvasBase(fig)
1848

Callers

nothing calls this directly

Calls 7

savefigMethod · 0.95
FigureClass · 0.90
FigureCanvasBaseClass · 0.90
figureMethod · 0.80
add_axesMethod · 0.80
imshowMethod · 0.80
imreadFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…