Skip to content

GaussianBlur does not work with I;16 #6667

Description

@amdepott

What did you do?

Attempted to use Image.filter(ImageFilter.BLUR) on an image of mode I or I;16

What did you expect to happen?

Image is blurred

What actually happened?

Code throws ValueError

What are your OS, Python and Pillow versions?

  • OS: Windows 10 Home
  • Python: 3.10.1
  • Pillow: 9.2.0
>>> from tkinter import filedialog
>>> from PIL import Image, ImageFilter
>>> image1 = Image.open(filedialog.askopenfilename())
>>> image1
   <PIL.BmpImagePlugin.BmpImageFile image mode=RGB size=630x514 at 0x28B7051E9B0>
>>> image2 = image1.convert('I')
>>> image2
   <PIL.Image.Image image mode=I size=630x514 at 0x28B70A8E560>
>>> image1.filter(ImageFilter.BLUR).show()
>>> image2.filter(ImageFilter.BLUR).show()
   Traceback (most recent call last):
     File "<pyshell#56>", line 1, in <module>
       image2.filter(ImageFilter.BLUR).show()
     File "C:\Users\x\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\Image.py", line 1247, in filter
       return self._new(filter.filter(self.im))
     File "C:\Users\x\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageFilter.py", line 32, in filter
       return image.filter(*self.filterargs)
   ValueError: image has wrong mode

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions