decrease captcha dots
This commit is contained in:
@@ -147,7 +147,7 @@ class UserViewSet(ModelViewSet):
|
||||
url_name='profile',
|
||||
url_path='profile',
|
||||
name='profile',
|
||||
permission_classes=[AllowAny]
|
||||
# permission_classes=[AllowAny]
|
||||
)
|
||||
def profile(self, request):
|
||||
serializer = authorize_view.UserRelationSerializer(
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import random
|
||||
|
||||
from rest_captcha import utils
|
||||
from rest_captcha.settings import api_settings
|
||||
from django.core.cache import caches
|
||||
@@ -5,6 +7,15 @@ from django.core.cache import caches
|
||||
cache = caches[api_settings.CAPTCHA_CACHE]
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
def noise_default(image, draw):
|
||||
draw = utils.noise_dots(draw, image, api_settings.CAPTCHA_FOREGROUND_COLOR)
|
||||
draw = noise_dots(draw, image, api_settings.CAPTCHA_FOREGROUND_COLOR)
|
||||
# draw = utils.noise_arcs(draw, image, api_settings.CAPTCHA_FOREGROUND_COLOR)
|
||||
|
||||
Reference in New Issue
Block a user