Skip to content

Resize not allowing filter parameter on 16 bit image #8333

@Zaaaane

Description

@Zaaaane

When attempting to resize a 16 bit image as shown below, a value error appears and crashes the program: "ValueError: image has wrong mode" The image type is "I;16"

The primary problem is that this worked without error in early July and hasn't been touched in a month. When I opened the code today it gave the error even when reverting to a previously stable version. Below is the relevant code inside a custom cropping method. The coord_tup variable is just a tuple that is working as expected

 new_im = im.crop(coord_tup)
 newSize = (640, 480)
 new_im = new_im.resize(newSize, resample=Image.Resampling.LANCZOS)
 npImg = np.asarray(new_im)
 return npImg

As stated this code used to work fine but when opened this week I get a value error on the line with the resize method, though it will technically work if I change the following

 new_im = new_im.resize(newSize, resample=Image.Resampling.LANCZOS)

->

 new_im = new_im.resize(newSize)

I understand through the API documentation that this should default to NEAREST but I could not find anything stating that LANCZOS would not work with 16 bit imaging

  • OS: macOS Sonoma 14.6.1 (23G93
  • Python: 3.12.3
  • Pillow: 10.4.0

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