Skip to content

Commit f4e54d4

Browse files
committed
more testing
1 parent 839562e commit f4e54d4

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

apps/discord-bot/assets/pet.gif

13.1 KB
Loading
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
using Discord;
22
using Discord.Interactions;
3-
using SixLabors.ImageSharp.Formats.Png;
3+
using SixLabors.ImageSharp;
4+
using SixLabors.ImageSharp.Formats.Gif;
45
using SixLabors.ImageSharp.PixelFormats;
5-
using SixLabors.ImageSharp.Processing;
6-
using ZstdSharp.Unsafe;
76

87
public partial class DiscordCommands : InteractionModuleBase
98
{
109
[SlashCommand("pet", "pet the kat")]
1110
public async Task pet([Summary("target", "user to harass")] IUser targetUser)
1211
{
13-
int size = 100;
12+
int sizeImage = 128;
13+
int sizeFull = 400;
1414
byte[] imageBytes;
15-
string saveLocation = "test2.png";
15+
string saveLocation = "test2.gif";
1616
string avatar = targetUser.GetAvatarUrl();
1717
var fetch = await Program.Client.GetAsync(avatar);
1818
var stream = await fetch.Content.ReadAsStreamAsync();
@@ -26,30 +26,36 @@ public async Task pet([Summary("target", "user to harass")] IUser targetUser)
2626

2727
stream.Close();
2828

29-
using (SixLabors.ImageSharp.Image image = SixLabors.ImageSharp.Image.Load(imageBytes))
30-
{
31-
image.Mutate(x => x.Resize(size, size));
32-
image.Save(outStream, new PngEncoder());
33-
}
29+
// metadata = image.Frames.RootFrame.Metadata.GetGifMetadata();
30+
// metadata.FrameDelay = frameDelay;
31+
32+
// // Add the color image to the gif.
33+
// gif.Frames.AddFrame(image.Frames.RootFrame);
3434

35-
using (SixLabors.ImageSharp.Image<Rgba32> fullImage = new(400, 400))
35+
// gif.SaveAsGif("output.gif");
36+
37+
using (Image<Rgba32> fullGif = new(sizeFull, sizeFull))
3638
{
37-
using (SixLabors.ImageSharp.Image avatarImage = SixLabors.ImageSharp.Image.Load(imageBytes))
39+
for (int frame = 0; frame < 5; frame++)
3840
{
39-
40-
for (int x = 0; x < size; x++)
41+
int offset = frame * 10;
42+
using (Image<Rgba32> frameImage = new(sizeFull, sizeFull))
43+
using (Image<Rgba32> avatarImage = SixLabors.ImageSharp.Image.Load<Rgba32>(imageBytes))
4144
{
42-
for (int y = 0; y < size; y++)
45+
for (int y = 0; y < sizeImage; y++)
4346
{
44-
// fullImage[x, y] = avatarImage.;
45-
47+
for (int x = 0; x < sizeImage; x++)
48+
{
49+
frameImage[x + offset, y + offset] = avatarImage[x, y];
50+
}
4651
}
4752

53+
fullGif.Frames.AddFrame(frameImage.Frames.RootFrame);
4854
}
49-
50-
fullImage[0, 0] = Rgba32.ParseHex("#FFFFFF");
51-
avatarImage.Save(outStream, new PngEncoder());
5255
}
56+
57+
GifEncoder encoder = new GifEncoder();
58+
fullGif.SaveAsPng(outStream);
5359
}
5460

5561
BinaryWriter bw = new BinaryWriter(outStream);
@@ -64,12 +70,6 @@ public async Task pet([Summary("target", "user to harass")] IUser targetUser)
6470
bw.Close();
6571
}
6672

67-
Embed embed = new EmbedBuilder()
68-
.WithColor(Color.Blue)
69-
.WithTitle("brazillian goes to the store with $1")
70-
.WithImageUrl(Settings.PUBLIC_PATH_RAMOJUSD_GIF_URL)
71-
.Build();
72-
7373
await RespondAsync("okay");
7474
}
7575
}

0 commit comments

Comments
 (0)