Unverified Commit d126f302 authored by Johannes L's avatar Johannes L Committed by GitHub
Browse files

[Enhancement] Add support for latest Pillow resampling filter naming scheme (#1931)

* Add support for latest Pillow resampling filter naming scheme

* Comments added

* Shortened comments, lint fixes

* Added specific Pillow version
parent 8b4dcf1d
......@@ -37,15 +37,27 @@ cv2_interp_codes = {
'lanczos': cv2.INTER_LANCZOS4
}
# Pillow >=v9.1.0 use a slightly different naming scheme for filters.
# Set pillow_interp_codes according to the naming scheme used.
if Image is not None:
pillow_interp_codes = {
'nearest': Image.NEAREST,
'bilinear': Image.BILINEAR,
'bicubic': Image.BICUBIC,
'box': Image.BOX,
'lanczos': Image.LANCZOS,
'hamming': Image.HAMMING
}
if hasattr(Image, 'Resampling'):
pillow_interp_codes = {
'nearest': Image.Resampling.NEAREST,
'bilinear': Image.Resampling.BILINEAR,
'bicubic': Image.Resampling.BICUBIC,
'box': Image.Resampling.BOX,
'lanczos': Image.Resampling.LANCZOS,
'hamming': Image.Resampling.HAMMING
}
else:
pillow_interp_codes = {
'nearest': Image.NEAREST,
'bilinear': Image.BILINEAR,
'bicubic': Image.BICUBIC,
'box': Image.BOX,
'lanczos': Image.LANCZOS,
'hamming': Image.HAMMING
}
def imresize(img,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment