pymsteams icon indicating copy to clipboard operation
pymsteams copied to clipboard

How could we include images from our computer?

Open ManuMillenaar opened this issue 6 years ago • 8 comments

It's only possible to add images from a URL, right?

Also, the hero image in the center would be super cool to have, if possible.

Thanks so much!

ManuMillenaar avatar Oct 10 '18 13:10 ManuMillenaar

You should encode image via base64

with open("path/to/image.jpg", "rb") as img_file: 
  encoded = base64.b64encode(img_file.read()).decode('ascii')
Session1.activityImage("data:image/jpeg;base64, "+str(encoded))

kapkanov avatar Nov 26 '21 08:11 kapkanov

Thanks @apolivin, this works for me. However, I get a 400 error when the image is too large. This might be related to #34

reesehopkins avatar Feb 16 '22 00:02 reesehopkins

The image within this activity is tiny. Is there a way to post a properly-sized image?

GitRon avatar May 18 '22 12:05 GitRon

OK, maybe you could update the docs that you can easily use HTML for larger images? 🙈 Thx for the great package!

GitRon avatar May 18 '22 12:05 GitRon

You can include an image as HTML, in a text block, as follows:

myTeamsMessage.text("<img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />")

LeonardoSanBenitez avatar Jul 26 '22 14:07 LeonardoSanBenitez

@LeonardoSanBenitez I know how to do it now but it's not mentioned in the docs 😃

GitRon avatar Aug 08 '22 07:08 GitRon

I want to attach about 119Kb png file. But, when i sent image, teams show below msg.

This message is too long to display here. Please visit the external source app to view the message.

How can i attach image?

chongjae avatar Oct 24 '22 06:10 chongjae

I want to attach about 119Kb png file. But, when i sent image, teams show below msg.

This message is too long to display here. Please visit the external source app to view the message.

How can i attach image?

It's a limitation of the api. The error message is suggesting you make the image available via external service, then link to it.

rveachkc avatar Oct 24 '22 20:10 rveachkc