captcha icon indicating copy to clipboard operation
captcha copied to clipboard

Can I generate the image by setting the resolution I want?

Open tony8888lrz opened this issue 2 years ago • 2 comments

For example, I want to generate a image(256*256) like this, how could I achieve that? image

tony8888lrz avatar May 29 '23 03:05 tony8888lrz

Can you explain it little more ?

dshaw0004 avatar Sep 16 '23 08:09 dshaw0004

@tony8888lrz Maybe... If you adjust the width/height, you can do it at the desired value You can also look at the code here for more information.

    width = 256
    height = 256
    font_sizes: tuple = (50, 58, 64)
    image = ImageCaptcha(width, height, font_sizes=font_sizes)
    captcha_text = '12g3r28ty324h32'
    id = image.generate(captcha_text)
    print("data:image/png;base64," + base64.b64encode(io.BytesIO(id.read()).getvalue()).decode(
            "utf-8"))

happylie avatar Dec 03 '23 04:12 happylie