Skip to content

A .net library for reading, modifying and writing TavernAI cards

Notifications You must be signed in to change notification settings

gitmylo/TavernAICardLib

Repository files navigation

TavernAI card lib .net

GitHub Workflow Status

Description

TavernAI card lib is a library for loading, modifying and saving TavernAI cards within a dotnet application.

It supports .json, .png, .webp, .jpg and .jpeg files. Although some of these formats have been untested so far.

Examples

Importing

using TavernAICardLib;

Loading

  • Loading a file from a .json
TavernAiCard card = TavernAiCard.Load("character.json");
  • Loading a file from an image
TavernAiCard card = TavernAiCard.Load("character.png");

Saving

  • Saving a .json
card.Save("character_saved.json");
  • Saving a .png
card.Save("character_saved.png");

Data reading and writing

  • Reading the name
string name = card.Name;
  • Writing the name
card.Name = "New name";

Image modification

  • Create an empty image for the card (Windows only).
// Check if bitmap image editing is supported, Windows only.
if (TavernAiCard.ImageFullySupported())
{
    // Create a transparent bitmap
    card.Image = new Bitmap(400, 600);
}
  • Setting the image to another image file
// Set Image to null in case it was already set from loading from an image file on Windows.
card.Image = null;
card.ImagePath = "path/to/the/image.png";

Card creation

  • Create simple card
// Instantiating, then setting properties
TavernAiCard card = new TavernAiCard();
// Giving a name
card.Name = "Name";

// Instantiating and declaring properties
TavernAiCard card = new TavernAiCard(){
    Name = "Name"
};
  • Create card with image from path
// Instantiating, then setting properties
TavernAiCard card = new TavernAiCard("path/to/the/image.png");
// Giving a name
card.Name = "Name";

// Instantiating and declaring properties
TavernAiCard card = new TavernAiCard("path/to/the/image.png"){
    Name = "Name"
};
  • Create card with image bitmap (Windows only)
// Instantiating, then setting properties
TavernAiCard card = new TavernAiCard(new Bitmap(400, 600));
// Giving a name
card.Name = "Name";

// Instantiating and declaring properties
TavernAiCard card = new TavernAiCard(new Bitmap(400, 600)){
    Name = "Name"
};

Card format conversion

  • Converting from .json to .png with an image from an existing file
TavernAiCard card = TavernAiCard.Load("character.json");
card.ImagePath = "path/to/the/image.png";
card.Save("character_saved.png");
  • Converting from .json to .png with a bitmap image (Windows only)
TavernAiCard card = TavernAiCard.Load("character.json");
card.Image = new Bitmap(400, 400);
card.Save("character_saved.png");
  • Converting from .png to .json
TavernAiCard card = TavernAiCard.Load("character.png");
card.Save("character_saved.json");

About

A .net library for reading, modifying and writing TavernAI cards

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages