Skip to content

Horizontally flip not correctly handling uint16 data #3500

@rainbean

Description

@rainbean

What did you do?

create an uint16 img and invoke img.transpose(Image.FLIP_LEFT_RIGHT)

What did you expect to happen?

horizontally flip the given PIL Image

What actually happened?

random data overflow

What are your OS, Python and Pillow versions?

  • OS: Ubuntu & macOS
  • Python: 3.6
  • Pillow: 5.1.0 ~ 5.3.0 tested
import numpy as np
from PIL import Image
x = np.zeros((10, 10), dtype=np.uint16)
x[1:4, 2:5] = 1
x[5:8, 5:8] = 2
y = Image.fromarray(x)
assert 2 == np.max(y)
y_ = y.transpose(Image.FLIP_LEFT_RIGHT)
assert 2 == np.max(y_) # error occurred, FLIP_TOP_BOTTOM is okay

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