Skip to content

unofficial API wrapper for Craiyon.com (formerly DALL-E-MINI)

License

Notifications You must be signed in to change notification settings

Nodoka4318/Craiyon.NET

Repository files navigation

Craiyon.NET

Overview

An unofficial API wrapper for Craiyon (formerly DALL-E-MINI) to generate awesome images from text tokens.
Simplest and easiest to use.

Inspired by craiyon.py.

Installation

you can get it from NuGet!
..or just copy & paste codes in this repo

Package Manager

Install-Package Craiyon.NET -Version 0.0.1

.NET CLI

dotnet add package Craiyon.NET --version 0.0.1

Usage

Generate and save images

var craiyon = new Craiyon.CraiyonClient(); // Create new instance
var images = craiyon.GenerateImage("what you want to see"); // Generate images

images.SaveImages("directory", "filename"); // Save images

↓ when you set "filename" to "craiyon-net" image

Generate images asynchronously

var craiyon = new Craiyon.CraiyonClient(); // Create new instance
var images = craiyon.GenerateImageAsync("what you want to see"); // Generate images

Generate images and convert into System.Drawing.Bitmap

var craiyon = new Craiyon.CraiyonClient(); // Create new instance
var images = craiyon.GenerateImage("what you want to see"); // Generate images

Bitmap[] bmps = images.ToBitmaps(); // Get bitmaps

macOS support

Since System.Drawing.Commons does not work on macOS, images need to be saved from byte arrays.

var craiyon = new Craiyon.CraiyonClient(); // Create new instance
var images = craiyon.GenerateImage("what you want to see"); // Generate images

byte[][] byteArrayImgs = images.ToByteArrays(); // Get byte arrays
for (int i = 0; i < byteArrayImgs.Length; i++) {
    var ms = new System.IO.MemoryStream(byteArrayImgs[i]);
    var fs = new System.IO.FileStream("filepath to save", FileMode.Create)
    ms.WriteTo(fs); // Write image data to filestream
}