Skip to content

Commit 7b194c6

Browse files
committed
Change constants usage to remove pillow future updates warnings
1 parent df13967 commit 7b194c6

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

qrcode/image/styledpil.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class StyledPilImage(qrcode.image.base.BaseImageWithDrawer):
3030
ensure that the QR code is still legible after the image has been placed
3131
there; Q or H level error correction levels are recommended to maintain
3232
data integrity A resampling filter can be specified (defaulting to
33-
PIL.Image.LANCZOS) for resizing; see PIL.Image.resize() for possible
33+
PIL.Image.Resampling.LANCZOS) for resizing; see PIL.Image.resize() for possible
3434
options for this parameter.
3535
"""
3636

@@ -45,7 +45,7 @@ def __init__(self, *args, **kwargs):
4545
embeded_image_path = kwargs.get("embeded_image_path", None)
4646
self.embeded_image = kwargs.get("embeded_image", None)
4747
self.embeded_image_resample = kwargs.get(
48-
"embeded_image_resample", Image.LANCZOS
48+
"embeded_image_resample", Image.Resampling.LANCZOS
4949
)
5050
if not self.embeded_image and embeded_image_path:
5151
self.embeded_image = Image.open(embeded_image_path)

qrcode/image/styles/moduledrawers/pil.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def initialize(self, *args, **kwargs):
8787
ImageDraw.Draw(self.circle).ellipse(
8888
(0, 0, fake_size, fake_size), fill=self.img.paint_color
8989
)
90-
self.circle = self.circle.resize((box_size, box_size), Image.LANCZOS)
90+
self.circle = self.circle.resize((box_size, box_size), Image.Resampling.LANCZOS)
9191

9292
def drawrect(self, box, is_active: bool):
9393
if is_active:
@@ -133,11 +133,11 @@ def setup_corners(self):
133133
base_draw.rectangle((radius, 0, fake_width, fake_width), fill=front_color)
134134
base_draw.rectangle((0, radius, fake_width, fake_width), fill=front_color)
135135
self.NW_ROUND = base.resize(
136-
(self.corner_width, self.corner_width), Image.LANCZOS
136+
(self.corner_width, self.corner_width), Image.Resampling.LANCZOS
137137
)
138-
self.SW_ROUND = self.NW_ROUND.transpose(Image.FLIP_TOP_BOTTOM)
139-
self.SE_ROUND = self.NW_ROUND.transpose(Image.ROTATE_180)
140-
self.NE_ROUND = self.NW_ROUND.transpose(Image.FLIP_LEFT_RIGHT)
138+
self.SW_ROUND = self.NW_ROUND.transpose(Image.Transpose.FLIP_TOP_BOTTOM)
139+
self.SE_ROUND = self.NW_ROUND.transpose(Image.Transpose.ROTATE_180)
140+
self.NE_ROUND = self.NW_ROUND.transpose(Image.Transpose.FLIP_LEFT_RIGHT)
141141

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

199-
self.ROUND_TOP = base.resize((shrunken_width, height), Image.LANCZOS)
200-
self.ROUND_BOTTOM = self.ROUND_TOP.transpose(Image.FLIP_TOP_BOTTOM)
199+
self.ROUND_TOP = base.resize((shrunken_width, height), Image.Resampling.LANCZOS)
200+
self.ROUND_BOTTOM = self.ROUND_TOP.transpose(Image.Transpose.FLIP_TOP_BOTTOM)
201201

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

252-
self.ROUND_LEFT = base.resize((width, shrunken_height), Image.LANCZOS)
253-
self.ROUND_RIGHT = self.ROUND_LEFT.transpose(Image.FLIP_LEFT_RIGHT)
252+
self.ROUND_LEFT = base.resize((width, shrunken_height), Image.Resampling.LANCZOS)
253+
self.ROUND_RIGHT = self.ROUND_LEFT.transpose(Image.Transpose.FLIP_LEFT_RIGHT)
254254

255255
def drawrect(self, box, is_active: "ActiveWithNeighbors"):
256256
if is_active:

0 commit comments

Comments
 (0)