0

I am using Bot Application Framework of C# to build a skype bot. I do some processing on image and then send it back to user in carousel of hero cards.

https://dev.skype.com/bots

I am following the constraints of the hero card, I am resizing image so that it's resolution is below 1024*1024, it's type is png/jpg and it's size is below 1MB. Also the link to the image is HTTPS://

Images loads in the web chat of https://dev.botframework.com every time, but when I use it on skype PC or Android it loads rarely.

This is how I am making the carousel.

var carousel = context.MakeMessage();
carousel.AttachmentLayout = AttachmentLayoutTypes.Carousel;
carousel.Attachments.Add(GetHeroCard(null, null, "Share this!", new CardImage(url: imageUrl, alt: imageUrl, tap: new CardAction(ActionTypes.ShowImage))));

This is how I am encoding Bitmap object to the png/jpeg format byte array to upload on the blob, from where I get the HTTPS link to the image.

public static byte[] BitmapEncode2Byte(Bitmap bitmap, ImageFormat format)
    {
        MemoryStream stream = new MemoryStream();
        EncoderParameters encoderParameters = new EncoderParameters(1);
        encoderParameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);
        bitmap.Save(stream, GetEncoder(ImageFormat.Png), encoderParameters);
        return stream.ToArray();
    }

    public static ImageCodecInfo GetEncoder(ImageFormat format)
    {
        ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
        foreach (ImageCodecInfo codec in codecs)
        {
            if (codec.FormatID == format.Guid)
            {
                return codec;
            }
        }
        return null;
    }

Thanks in Advance!

  • Try making it much smaller. I have seen issues where if a bot can't load the image in time it just sends the message anyway. Where's the file hosted? – stuartd Jun 29 '17 at 09:45
  • I use azure blob storage, and the images in most cases smaller than 500KB, and in resolution the max of width or height is 1024, other is way less than that. Should I go to much smaller size than this? – Sagar Kamdar Jun 29 '17 at 13:12

0 Answers0