0

I want to output an image to the channel using the Imagesharp framework, or rather I'm new to This framework. Initially, I got this error "Can't convert from" SixLabors.ImageSharp.Image "to"string". I tried to solve the problem by writing string a = $ " {zx}"; await ReplyAsync(a) and it didn't work.

    int Width = 640;
    int Height = 480;

    [Command("cmd")]
    public async Task TestCmd()
    {
        

        var zx = Image.Load("Images/1ub.jpg");
        {
            
            zx.Mutate(x => x.Resize(zx.Width / 2, zx.Height / 2));

            zx.Save("Images/1ub.jpg");
          
        }

        string a = $"{zx}";
       

        await ReplyAsync(a);
    }
white cat
  • 3
  • 3
  • You can't post an image as a string. Use `SendFileAsync` to send the image. – Anu6is Aug 15 '20 at 17:38
  • @Anu6is he writes to me: I can't convert from "SixLabors.ImageSharp.Image" to " string" – white cat Aug 15 '20 at 18:42
  • you either send a filepath as a string or you send the file as stream – Anu6is Aug 15 '20 at 18:55
  • @Anu6is Yes, you are right I send as a string, tell me how to send as a file – white cat Aug 15 '20 at 19:23
  • if you are saving the file to disk then just send the save location. – Anu6is Aug 15 '20 at 19:43
  • @Anu6is Well, you helped me but not the way I wanted, it turned out so I added the path to the image in await and it went to my channel but if I add a variable to await the image will not come out :( – white cat Aug 15 '20 at 20:35
  • @Anu6is But no you helped me I have polucilasi, thank you very much :) – white cat Aug 15 '20 at 20:54
  • I really think you need to take the time to learn C# before continuing so that you understand how string interpolation works. You're also leaking memory for every image. – James South Aug 19 '20 at 16:31

0 Answers0