mirror of
https://github.com/lepture/captcha.git
synced 2026-03-13 09:43:22 +08:00
chore: release 0.6.0
This commit is contained in:
@@ -7,6 +7,12 @@ Changelog
|
||||
|
||||
----
|
||||
|
||||
v0.6.0
|
||||
------
|
||||
|
||||
Released on Jul 18, 2024
|
||||
|
||||
- Add character settings for ``ImageCaptcha``.
|
||||
|
||||
v0.5.0
|
||||
------
|
||||
|
||||
@@ -68,3 +68,30 @@ specific endpoint.
|
||||
code = "ABCD"
|
||||
data = image.generate(code)
|
||||
return Response(data, mimetype="image/png")
|
||||
|
||||
Character Settings
|
||||
------------------
|
||||
|
||||
.. versionadded:: 0.6
|
||||
|
||||
Update the default settings to change the character renderring.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from captcha.image import ImageCaptcha
|
||||
|
||||
captcha = ImageCaptcha()
|
||||
captcha.character_rotate = (-40, 40)
|
||||
captcha.generate("ABCD")
|
||||
|
||||
Available options:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
character_offset_dx: tuple[int, int] = (0, 4)
|
||||
character_offset_dy: tuple[int, int] = (0, 6)
|
||||
character_rotate: tuple[int, int] = (-30, 30)
|
||||
character_warp_dx: tuple[float, float] = (0.1, 0.3)
|
||||
character_warp_dy: tuple[float, float] = (0.2, 0.3)
|
||||
word_space_probability: float = 0.5
|
||||
word_offset_dx: float = 0.25
|
||||
|
||||
@@ -10,6 +10,6 @@
|
||||
:license: BSD, see LICENSE for more details.
|
||||
"""
|
||||
|
||||
__version__ = '0.5.0'
|
||||
__version__ = '0.6.0'
|
||||
__author__ = 'Hsiaoming Yang <me@lepture.com>'
|
||||
__homepage__ = 'https://github.com/lepture/captcha'
|
||||
|
||||
@@ -48,7 +48,7 @@ class ImageCaptcha:
|
||||
lookup_table: list[int] = [int(i * 1.97) for i in range(256)]
|
||||
character_offset_dx: tuple[int, int] = (0, 4)
|
||||
character_offset_dy: tuple[int, int] = (0, 6)
|
||||
chracter_rotate: tuple[int, int] = (-30, 30)
|
||||
character_rotate: tuple[int, int] = (-30, 30)
|
||||
character_warp_dx: tuple[float, float] = (0.1, 0.3)
|
||||
character_warp_dy: tuple[float, float] = (0.2, 0.3)
|
||||
word_space_probability: float = 0.5
|
||||
@@ -121,7 +121,7 @@ class ImageCaptcha:
|
||||
# rotate
|
||||
im = im.crop(im.getbbox())
|
||||
im = im.rotate(
|
||||
random.uniform(*self.chracter_rotate),
|
||||
random.uniform(*self.character_rotate),
|
||||
BILINEAR,
|
||||
expand=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user