Skip to content

Commit

Permalink
chore: release 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Jul 18, 2024
1 parent 01ac0b0 commit bd892b7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
6 changes: 6 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Changelog

----

v0.6.0
------

Released on Jul 18, 2024

- Add character settings for ``ImageCaptcha``.

v0.5.0
------
Expand Down
27 changes: 27 additions & 0 deletions docs/image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/captcha/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
:license: BSD, see LICENSE for more details.
"""

__version__ = '0.5.0'
__version__ = '0.6.0'
__author__ = 'Hsiaoming Yang <[email protected]>'
__homepage__ = 'https://github.com/lepture/captcha'
4 changes: 2 additions & 2 deletions src/captcha/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -121,7 +121,7 @@ def _draw_character(
# rotate
im = im.crop(im.getbbox())
im = im.rotate(
random.uniform(*self.chracter_rotate),
random.uniform(*self.character_rotate),
BILINEAR,
expand=True,
)
Expand Down

1 comment on commit bd892b7

@TruncatedDinoSour
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Please sign in to comment.