Skip to content

Commit

Permalink
Change constants usage to remove pillow future updates warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
alfreedom committed Aug 27, 2022
1 parent df13967 commit 7b194c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions qrcode/image/styledpil.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class StyledPilImage(qrcode.image.base.BaseImageWithDrawer):
ensure that the QR code is still legible after the image has been placed
there; Q or H level error correction levels are recommended to maintain
data integrity A resampling filter can be specified (defaulting to
PIL.Image.LANCZOS) for resizing; see PIL.Image.resize() for possible
PIL.Image.Resampling.LANCZOS) for resizing; see PIL.Image.resize() for possible
options for this parameter.
"""

Expand All @@ -45,7 +45,7 @@ def __init__(self, *args, **kwargs):
embeded_image_path = kwargs.get("embeded_image_path", None)
self.embeded_image = kwargs.get("embeded_image", None)
self.embeded_image_resample = kwargs.get(
"embeded_image_resample", Image.LANCZOS
"embeded_image_resample", Image.Resampling.LANCZOS
)
if not self.embeded_image and embeded_image_path:
self.embeded_image = Image.open(embeded_image_path)
Expand Down
18 changes: 9 additions & 9 deletions qrcode/image/styles/moduledrawers/pil.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def initialize(self, *args, **kwargs):
ImageDraw.Draw(self.circle).ellipse(
(0, 0, fake_size, fake_size), fill=self.img.paint_color
)
self.circle = self.circle.resize((box_size, box_size), Image.LANCZOS)
self.circle = self.circle.resize((box_size, box_size), Image.Resampling.LANCZOS)

def drawrect(self, box, is_active: bool):
if is_active:
Expand Down Expand Up @@ -133,11 +133,11 @@ def setup_corners(self):
base_draw.rectangle((radius, 0, fake_width, fake_width), fill=front_color)
base_draw.rectangle((0, radius, fake_width, fake_width), fill=front_color)
self.NW_ROUND = base.resize(
(self.corner_width, self.corner_width), Image.LANCZOS
(self.corner_width, self.corner_width), Image.Resampling.LANCZOS
)
self.SW_ROUND = self.NW_ROUND.transpose(Image.FLIP_TOP_BOTTOM)
self.SE_ROUND = self.NW_ROUND.transpose(Image.ROTATE_180)
self.NE_ROUND = self.NW_ROUND.transpose(Image.FLIP_LEFT_RIGHT)
self.SW_ROUND = self.NW_ROUND.transpose(Image.Transpose.FLIP_TOP_BOTTOM)
self.SE_ROUND = self.NW_ROUND.transpose(Image.Transpose.ROTATE_180)
self.NE_ROUND = self.NW_ROUND.transpose(Image.Transpose.FLIP_LEFT_RIGHT)

def drawrect(self, box: List[List[int]], is_active: "ActiveWithNeighbors"):
if not is_active:
Expand Down Expand Up @@ -196,8 +196,8 @@ def setup_edges(self):
base_draw = ImageDraw.Draw(base)
base_draw.ellipse((0, 0, fake_width, fake_height * 2), fill=front_color)

self.ROUND_TOP = base.resize((shrunken_width, height), Image.LANCZOS)
self.ROUND_BOTTOM = self.ROUND_TOP.transpose(Image.FLIP_TOP_BOTTOM)
self.ROUND_TOP = base.resize((shrunken_width, height), Image.Resampling.LANCZOS)
self.ROUND_BOTTOM = self.ROUND_TOP.transpose(Image.Transpose.FLIP_TOP_BOTTOM)

def drawrect(self, box, is_active: "ActiveWithNeighbors"):
if is_active:
Expand Down Expand Up @@ -249,8 +249,8 @@ def setup_edges(self):
base_draw = ImageDraw.Draw(base)
base_draw.ellipse((0, 0, fake_width * 2, fake_height), fill=front_color)

self.ROUND_LEFT = base.resize((width, shrunken_height), Image.LANCZOS)
self.ROUND_RIGHT = self.ROUND_LEFT.transpose(Image.FLIP_LEFT_RIGHT)
self.ROUND_LEFT = base.resize((width, shrunken_height), Image.Resampling.LANCZOS)
self.ROUND_RIGHT = self.ROUND_LEFT.transpose(Image.Transpose.FLIP_LEFT_RIGHT)

def drawrect(self, box, is_active: "ActiveWithNeighbors"):
if is_active:
Expand Down

0 comments on commit 7b194c6

Please sign in to comment.