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.
- 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 a .json
card.Save("character_saved.json");
- Saving a .png
card.Save("character_saved.png");
- Reading the name
string name = card.Name;
- Writing the name
card.Name = "New name";
- 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";