Deprecate ImageOps undocumented functions

This commit is contained in:
Alexander 2017-09-14 01:48:27 +03:00
parent 3b5c2c30be
commit d5f069472d

View File

@ -21,6 +21,7 @@ from . import Image
from ._util import isStringType from ._util import isStringType
import operator import operator
import functools import functools
import warnings
# #
@ -437,6 +438,13 @@ def solarize(image, threshold=128):
def gaussian_blur(im, radius=None): def gaussian_blur(im, radius=None):
""" PIL_usm.gblur(im, [radius])""" """ PIL_usm.gblur(im, [radius])"""
warnings.warn(
'PIL.ImageOps.gaussian_blur is deprecated. '
'Use PIL.ImageFilter.GaussianBlur instead. '
'This function will be removed in a future version.',
DeprecationWarning
)
if radius is None: if radius is None:
radius = 5.0 radius = 5.0
@ -444,12 +452,30 @@ def gaussian_blur(im, radius=None):
return im.im.gaussian_blur(radius) return im.im.gaussian_blur(radius)
gblur = gaussian_blur
def gblur(im, radius=None):
""" PIL_usm.gblur(im, [radius])"""
warnings.warn(
'PIL.ImageOps.gblur is deprecated. '
'Use PIL.ImageFilter.GaussianBlur instead. '
'This function will be removed in a future version.',
DeprecationWarning
)
return gaussian_blur(im, radius)
def unsharp_mask(im, radius=None, percent=None, threshold=None): def unsharp_mask(im, radius=None, percent=None, threshold=None):
""" PIL_usm.usm(im, [radius, percent, threshold])""" """ PIL_usm.usm(im, [radius, percent, threshold])"""
warnings.warn(
'PIL.ImageOps.unsharp_mask is deprecated. '
'Use PIL.ImageFilter.UnsharpMask instead. '
'This function will be removed in a future version.',
DeprecationWarning
)
if radius is None: if radius is None:
radius = 5.0 radius = 5.0
if percent is None: if percent is None:
@ -461,7 +487,18 @@ def unsharp_mask(im, radius=None, percent=None, threshold=None):
return im.im.unsharp_mask(radius, percent, threshold) return im.im.unsharp_mask(radius, percent, threshold)
usm = unsharp_mask
def usm(im, radius=None, percent=None, threshold=None):
""" PIL_usm.usm(im, [radius, percent, threshold])"""
warnings.warn(
'PIL.ImageOps.usm is deprecated. '
'Use PIL.ImageFilter.UnsharpMask instead. '
'This function will be removed in a future version.',
DeprecationWarning
)
return unsharp_mask(im, radius, percent, threshold)
def box_blur(image, radius): def box_blur(image, radius):
@ -478,6 +515,13 @@ def box_blur(image, radius):
in each direction, i.e. 9 pixels in total. in each direction, i.e. 9 pixels in total.
:return: An image. :return: An image.
""" """
warnings.warn(
'PIL.ImageOps.box_blur is deprecated. '
'Use PIL.ImageFilter.BoxBlur instead. '
'This function will be removed in a future version.',
DeprecationWarning
)
image.load() image.load()
return image._new(image.im.box_blur(radius)) return image._new(image.im.box_blur(radius))