Lpd.ImageFaker.Core 1.0.1

dotnet add package Lpd.ImageFaker.Core --version 1.0.1                
NuGet\Install-Package Lpd.ImageFaker.Core -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Lpd.ImageFaker.Core" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Lpd.ImageFaker.Core --version 1.0.1                
#r "nuget: Lpd.ImageFaker.Core, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Lpd.ImageFaker.Core as a Cake Addin
#addin nuget:?package=Lpd.ImageFaker.Core&version=1.0.1

// Install Lpd.ImageFaker.Core as a Cake Tool
#tool nuget:?package=Lpd.ImageFaker.Core&version=1.0.1                

Lpd.ImageFaker.Core - Overview

  • You may use this class library for creating Image from text lines or any object
  • You should use Windows version of this library - Lpd.ImageFaker.Windows in apps for Windows
  • It was created for Lpd.ObjectFaker as utility for dotnet core projects
  • Lpd.ObjectFaker was created for Lpd tests via Personal Data Fake objects
  • Reminder: You would use Lpd class library for GDPR and/or PCI DSS requirements implementation in your apps

Lpd.ImageFaker.Core - Classes

  • ImageOptions: You MUST set fontname from OS, new ImageOptions().SetFontName(@"c:\windows\fonts\arial.ttf")
  • ImagePainter: draw text lines
  • ObjectPainter: draw serialization of object
  • Library tested for .core 8, created for .core 6
  • Look at full example below images

Example of images as result

  • Tammy_Parks.png
  • Douglas_Parker.png

Lpd.ImageFaker.Core - Example of images for 'Person' object

  • Create Console App
  • Install-package Lpd.ObjectFaker
  • Install-package Lpd.ImageFaker.Core
  • Install-package Newtonsoft.Json
  • Replace default source code for

using Lpd.ImageFaker.Core;

using Lpd.ObjectFaker;
using Lpd.ObjectFaker.Exts;

using Newtonsoft.Json;

Console.WriteLine("Hello, World!");

var SimplePersonRandom = PersonGenerator.CreateBuilderFor_RandomSimplePerson();

for ( int i = 0; i < 10; i++ )
{
    var person = SimplePersonRandom.Get();
    File.WriteAllBytes($@"c:\02\{person.Name}-{person.Surname}-{Environment.TickCount}.png", person.Image);
    Console.WriteLine( person);
}

Console.WriteLine("Press any key to exit...");
Console.ReadKey();


public class SimplePerson
{
    public string Id { get; set; }

    public string Name { get; set; }

    public string Surname { get; set; }

    public string Email { get; set; }

    public byte[] Image { get; set; } = null;

    public override string ToString()
    {
        return JsonConvert.SerializeObject(this, Formatting.Indented);
    }
}

public static class PersonGenerator
{
    public static GeneratorBuilder<SimplePerson> CreateBuilderFor_RandomSimplePerson()
    {
        var builder = new GeneratorBuilder<SimplePerson>(new SimplePerson());
        builder
            .With(x => x.Id, () => System.Guid.NewGuid().ToString())
            .With(x => x.Name, () => Lpd.ObjectFaker.RandomItem<string>.Random(new Lpd.ObjectFaker.Pops.NamesList().ToArray()))
            .With(x => x.Surname, () => Lpd.ObjectFaker.RandomItem<string>.Random(new Lpd.ObjectFaker.Pops.SurnamesList().ToArray()))
            .WithSelf(x => x.Email, it => $"{it.GetCurrentState().Name}-{it.GetCurrentState().Surname}@example.com")
            .WithSelf(x => x.Image, it => ObjectPainter.Get(new ImageOptions() .SetFontName(@"c:\windows\fonts\arial.ttf"), it.GetCurrentState()).ToArray()
            )
            ;

        //it will generate by setters when you call Get()
        return builder;
    }

}

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 71 1/19/2025
1.0.0 109 11/28/2024

It would be a part of Lpd.ObjectFaker