Giter Site home page Giter Site logo

aliasadidev / sixlaborscaptcha Goto Github PK

View Code? Open in Web Editor NEW
47.0 47.0 7.0 113 KB

Generate captcha with SixLabors' libraries on .NET Core

License: Apache License 2.0

C# 100.00%
asp-net-core aspnetcore captcha docker dotnet-standard linux-app windows-app

sixlaborscaptcha's Introduction

Hi there, I'm Ali ๐Ÿ‘‹

I'm a senior full-stack developer

  • ๐Ÿ”ญ I launched my first extension: NuGet Package Manager GUI
  • ๐ŸŒฑ I'm currently learning everything
  • ๐Ÿฅ… 2024 Goals: Contribute more to Open Source projects

Top Langs

Connect with me:

Ali Asadi linkedin


sixlaborscaptcha's People

Contributors

aliasadidev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sixlaborscaptcha's Issues

Method not found: 'SixLabors.Fonts.FontRectangle SixLabors.Fonts.TextMeasurer.Measure

Hello,
Recently upgraded to dotnet core 8.x and ClosedXML also upgraded to 0.102.0 which is using latest version of SixLabors.Fonts.

Got the following exception during captcha image generation.

System.MissingMethodException: Method not found: 'SixLabors.Fonts.FontRectangle SixLabors.Fonts.TextMeasurer.Measure(System.String, SixLabors.Fonts.TextOptions)'. at SixLaborsCaptcha.Core.SixLaborsCaptchaModule.Generate(String stringText)

Dotnet Info:
.NET SDK:
Version: 8.0.100
Commit: 57efcf1350
Workload version: 8.0.100-manifests.3b83835e

Runtime Environment:
OS Name: Mac OS X
OS Version: 14.3
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/8.0.100/

may be upgrading the the SixLabors.Fonts should fix the issue

linux fonts not working

SixLabors.Fonts.FontFamilyNotFoundException: 'The "Ariel" font family could not be found in the following directories:

  • /usr/local/share/fonts/
  • /usr/share/fonts/'

Install cabextract, a tool needed to unpack self-extracting .exe archives:

sudo apt install cabextract
Download the font package provided via this page (also note the EULA there):

wget https://www.freedesktop.org/software/fontconfig/webfonts/webfonts.tar.gz
Unpack, twice:

tar -xzf webfonts.tar.gz
cd msfonts/
cabextract *.exe
Move the fonts to your user's directory for installing additional fonts:

cp *.ttf *.TTF ~/.local/share/fonts/

cp *.ttf *.TTF /usr/local/share/fonts/

https://askubuntu.com/a/1092920

Font family not found in RHEL7 with error SixLabors.Fonts.FontFamilyNotFoundException

I am trying to run my app on Kubernetes RHEL server. But every time i am getting SixLabors.Fonts.FontFamilyNotFoundException.
I have double checked and verified that the font is available inside /usr/share/fonts/. I have also tried adding a custom font as described in readme file but still no luck. Here is stackstace for same.

this is my code

 public async Task<string> GetCaptchaImage(string test)
        {
            _log.LogInformation(string.Format("GetCaptchaImage- Font name is {0}", Environment.GetEnvironmentVariable("font_name")));
            _log.LogInformation(string.Format("GetCaptchaImage- A bitmap of 130x80"));
            var slc = new SixLaborsCaptchaModule(new SixLaborsCaptchaOptions
            {
                DrawLines = 7,
                TextColor = new Color[] { Color.Blue, Color.Black },
                Width = 130,
                Height = 80,
                FontFamilies = new string[] { Environment.GetEnvironmentVariable("font_name") },
            });
            _log.LogInformation(string.Format("GetCaptchaImage- Generating random text"));
            var captchaText = Extentions.GetUniqueKey(6).ToUpper();
            _log.LogInformation(string.Format("GetCaptchaImage- Generating bitmap..."));
            var images = slc.Generate(captchaText);  // this is line 945
            _log.LogInformation(string.Format("GetCaptchaImage- Returning base64 image..."));
            return Convert.ToBase64String(images);
        }
DejaVuSans could not be found.  
SixLabors.Fonts.FontFamilyNotFoundException
"   at SixLabors.Fonts.FontCollection.GetImpl(String name CultureInfo culture)
   at SixLabors.Fonts.FontCollection.Get(String name)
   at SixLabors.Fonts.SystemFontCollection.Get(String name)
   at SixLabors.Fonts.SystemFonts.CreateFont(String name Single size FontStyle style)
   at SixLaborsCaptcha.Core.SixLaborsCaptchaModule.Generate(String stringText)
   at classname.GetCaptchaImage(String msisdn) 
   in Classname.cs:line 945
   at Clanname.GetCaptcha(String msisdn) in 
   classname.cs:line 609"

image

MissingMethodException

After a project upgrade from .net5 to .net6 and an upgrade to the latest SixLabors.ImageSharp version 2.1.0 (which is needed for my project) the library does not seem to work anymore. I get the following exception:

MissingMethodException: Method not found: 'System.Span1<SixLabors.ImageSharp.PixelFormats.Rgba32> SixLabors.ImageSharp.Memory.Buffer2D1.GetRowSpan(Int32)'.

Do you have any plans to upgrade your project anytime soon in order to work with the latest SixLabors.ImageSharp version?
Thank you very much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.