def bg_custom_fn(bg): # do something you wanted # return bg.filter(ImageFilter.GaussianBlur) CaptchaUtils.draw_line( bg, (0, CaptchaUtils.random_choice_from(range(12, 14))), (85, CaptchaUtils.random_choice_from(range(13, 15))), CaptchaUtils.get_rgb("0x595e12"), 1) CaptchaUtils.draw_line( bg, (0, CaptchaUtils.random_choice_from(range(11, 16))), (85, CaptchaUtils.random_choice_from(range(17, 21))), CaptchaUtils.get_rgb("0x563c7c"), 1) return bg
def draw_noise_curve(self, color="0x484848", number=4, width=3, type="line"): points = [ CaptchaUtils.random_point(self._width, self._height) for i in range(number + 1) ] if type == "line": for idx in range(len(points) - 1): CaptchaUtils.draw_line(self._captcha, points[idx], points[idx + 1], CaptchaUtils.get_rgb(color), width) elif type == "curve": pass # CaptchaUtils.draw_curve() else: pass