python-pillow / python-pillow/Pillow

GaussianBlur does not work with I;16

Open
#6,667 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
13.8k
Forks
2.5k
Avg merge
2d 8h
Merged PRs (30d)
89

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The traceback points to PIL.Image.filter and PIL.ImageFilter.BLUR; start by reproducing the example with I and I;16 images and inspect where the wrong-mode error is raised. Done means the blur filter works for those modes without raising ValueError, with behavior checked against the reported expectation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.