SimpleImageEdit

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using var api = GetAuthenticatedClient();

FileInfo originalFileInfo = new($"{Guid.NewGuid()}.png");

await File.WriteAllBytesAsync(originalFileInfo.FullName, H.Resources.images_flower_vase_png.AsBytes());

Console.WriteLine($"Original Image available at:\n{new Uri(originalFileInfo.FullName).AbsoluteUri}");

FileInfo maskFileInfo = new($"{Guid.NewGuid()}.png");

await File.WriteAllBytesAsync(maskFileInfo.FullName, H.Resources.images_flower_vase_mask_png.AsBytes());

Console.WriteLine($"Mask available at:\n{new Uri(maskFileInfo.FullName).AbsoluteUri}");

ImagesResponse image = await api.Images.CreateImageEditAsync(
    image: H.Resources.images_flower_vase_png.AsBytes(),
    imagename: H.Resources.images_flower_vase_png.FileName,
    prompt: "A vase full of beautiful flowers.",
    mask: H.Resources.images_flower_vase_mask_png.AsBytes(),
    maskname: H.Resources.images_flower_vase_mask_png.FileName,
    model: CreateImageEditRequestModel.DallE2,
    size: CreateImageEditRequestSize.x512x512,
    responseFormat: CreateImageEditRequestResponseFormat.B64Json);
byte[] bytes = image.Data[0].Bytes;

FileInfo fileInfo = new($"{Guid.NewGuid()}.png");

await File.WriteAllBytesAsync(fileInfo.FullName, bytes);

Console.WriteLine($"Image available at:\n{new Uri(fileInfo.FullName).AbsoluteUri}");