Generate a simple digits captcha image

There are some generate PNG shards. but i don’t know how to make image with text in it.

I found some example code in pixie shards works for what i need, but the example code not work on my Arch Linux, check this issue.

Right now, I just want to make a small, simple picture with some numbers on it. It will be used as a simple check when people sign up on my website.

Thanks.

This file has code doing it. If you want I can do a more minimal example.

Thanks a lot, will be check later.

I found another working solution, which use crystal-vips.

4560f5ede927992c21343aff21d3c440

1 Like

Create a captcha shard use naqvis/crystal-vips

All credits goes to the example code in crystal-vips by @naqvis

1 Like

I don’t think this will be viable for a text-based captcha implementation but for the general case where the images looks relatively the same you could get away with just creating SVGs and then converting to a PNG.

The clock captchas that Invidious uses during registrations are generated this way by manipulating SVG attributes on each picture:

3 Likes

There is a sister shard, name simple_captcha

All credits goes to @Sunrise

The different is:

  • SimpleCaptcha has no external dependencies other than Crystal,so, you can
    built static binary (if this is your’s need)
  • this shard captcha code only support number.

These two libraries should be interchangeable without the need to change you code.

image

1 Like