2018年8月26日日曜日

開発環境

  • OS: macOS High Sierra - Apple
  • Text Editor: Emacs
  • プログラミング言語: Python3
  • Package: Pillow

以前の投稿について、

ということで、とりあえず簡単に確認してみた。(各アルゴリズムの詳細までは調べてない。)

コード(Emacs)

Python 3

#!/usr/bin/env python3
from PIL import Image

pil_im = Image.open('PNG_transparency_demonstration_2.png')

help(pil_im.thumbnail)

入出力結果(Terminal, Jupyter(IPython))

$ ./sample.py
Help on method thumbnail in module PIL.Image:

thumbnail(size, resample=3) method of PIL.PngImagePlugin.PngImageFile instance
    Make this image into a thumbnail.  This method modifies the
    image to contain a thumbnail version of itself, no larger than
    the given size.  This method calculates an appropriate thumbnail
    size to preserve the aspect of the image, calls the
    :py:meth:`~PIL.Image.Image.draft` method to configure the file reader
    (where applicable), and finally resizes the image.
    
    Note that this function modifies the :py:class:`~PIL.Image.Image`
    object in place.  If you need to use the full resolution image as well,
    apply this method to a :py:meth:`~PIL.Image.Image.copy` of the original
    image.
    
    :param size: Requested size.
    :param resample: Optional resampling filter.  This can be one
       of :py:attr:`PIL.Image.NEAREST`, :py:attr:`PIL.Image.BILINEAR`,
       :py:attr:`PIL.Image.BICUBIC`, or :py:attr:`PIL.Image.LANCZOS`.
       If omitted, it defaults to :py:attr:`PIL.Image.BICUBIC`.
       (was :py:attr:`PIL.Image.NEAREST` prior to version 2.5.0)
    :returns: None

$

標準では\助けよや/さんの言う通り、BICUBIC法みたい。以前はNEAREST法だった模様。(引数での設定によって、NEAREST、BILINEAR、LANCZOS algorithm も選択可能。)

0 コメント:

コメントを投稿