question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Downloading an Image from a DM

See original GitHub issue

Im trying to download an image with the “DownloadBinary” method from the TwitterAccessor class but i always get the result of an “Invalid parameter” in line 11


1. byte[] b_imageData = TwitterAccessor.DownloadBinary("https://ton.twitter.com/i/ton/data/dm/842103797698723851/842103786856448005/JWPa2oer.jpg");
2. byte[] b_imageFromDisc = File.ReadAllBytes(@"C:\JWPa2oer.jpg");
3. //DEBUG output
4. ConsoleHandler.CMsg(b_imageData.Length.ToString(), ConsoleColor.Cyan);      //OUTPUT: 122755
5. ConsoleHandler.CMsg(b_imageFromDisc.Length.ToString(), ConsoleColor.Cyan); //OUTPUT: 123779
6. 
7. try
8. {
9. 
10.     using (MemoryStream MS = new MemoryStream(b_imageData))
11.         using (Image Img = Image.FromStream(MS))
12.             Img.Save(@"C:\output.jpg", ImageFormat.Jpeg);
13. 
14. }catch(Exception ex)
15. {
16.     ConsoleHandler.CMsg(ex.Message, ConsoleColor.Cyan);
17. }

The code works if i read the picture from my pc. So is something wrong with my download attempt?

Thanks.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
linvicommented, Mar 15, 2017

Twitter does not support such operation. I tried in the past to access the TON API to get the image for DM but the binary they return is not a properly formatted image.

0reactions
linvicommented, Oct 29, 2017

#550 @pal5hahnair apparently solved this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to download pics from Instagram DM's to your phone
To download dm pictures you can use two ways to solve this by just taking a screenshot of the image and you crop...
Read more >
3 Ways to Download Photos, Videos from Twitter Direct ...
1. Tap on the image you wish to Save. download photos videos Twitter DM · 2. Right Click and click on Save Image...
Read more >
Is there a way to download all photos from a DM on discord?
You can export the DM using the Discrub chrome extension, and if you toggle the 'Download Images' option, all message media attachments will ......
Read more >
How to Save Instagram DM Videos to Gallery in 2023?
Step 2: Tap and long press on the video/image until the pop-up comes. Step 3: In a small window, you'll see the Save...
Read more >
How To Save Pictures From Instagram Direct Message
In this article we will show you how to save pictures from Instagram direct message, nowadays Instagram is trending, everyone like 8 out...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found