Files

22 lines
606 B
Python
Raw Permalink Normal View History

2025-05-28 16:26:01 +03:30
import random
2025-05-04 15:24:28 +03:30
from rest_captcha import utils
from rest_captcha.settings import api_settings
from django.core.cache import caches
cache = caches[api_settings.CAPTCHA_CACHE]
2025-05-28 16:26:01 +03:30
def noise_dots(draw, image, fill):
size = image.size
for p in range(int(size[0] * size[1] * 0.07)):
x = random.randint(0, size[0])
y = random.randint(0, size[1])
draw.point((x, y), fill=fill)
return draw
2025-05-04 15:24:28 +03:30
def noise_default(image, draw):
2025-05-28 16:26:01 +03:30
draw = noise_dots(draw, image, api_settings.CAPTCHA_FOREGROUND_COLOR)
2025-05-04 15:24:28 +03:30
# draw = utils.noise_arcs(draw, image, api_settings.CAPTCHA_FOREGROUND_COLOR)