2

use the python3 Pillow lib to make an image rotation on a custom angle(for example 37 degrees). As the result my image has a artefact - ribbed border. Could you please help to avoid this artefact?

Env:

OS: macOS/Ubuntu 18.04

Python version: 3.9.13

Pillow version: 8.1.2/9.2.0

Code sample:

from PIL import Image

im = Image.open('asset.png')
im = im.rotate(37, resample=Image.BICUBIC, expand=True, fillcolor=(255, 0, 0))
im.save('rotated_asset.png')

Input asset:

asset

Result:

rotated_asset_for_37_degrees

zoomed_part

Kirill K
  • 21
  • 2

1 Answers1

0

The artifact you are noticing is known as aliasing. Removing that using PIL is going to be complex. You could try using the openCV library instead, but it may show the same effect.

See here: Is there an antialiasing method for Python PIL?

Pete
  • 55
  • 5
  • Hello Pete, thank you for the answer. Yes, I checked openCV and it does not have aliasing, may be for my case. But I worked with Pillow 2 years and a major pipeline part use the Pillow, it significant changes. Also, I checked the ANTIALIAS resample, it does not supported for the rotate tool. – Kirill K Oct 11 '22 at 16:22