開発環境
以前の投稿について、
ということで、とりあえず簡単に確認してみた。(各アルゴリズムの詳細までは調べてない。)https://t.co/ueXnY6Hfoh
— \助けよや/ (@yoya) 2018年8月26日
あれ。。てっきり Lanczos 使ってると思ってたけど、PIL thumnail はデフォルト BICUBIC でそっちに似てる? ちょっと検証してみるか。確か PIL のは α:-0.5 なのでエルミートだったような。(BCファミリーの中でもあんまり良くないやつ)
コード(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 コメント:
コメントを投稿