Downloading an Image from a DM
See original GitHub issueIm 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:
- Created 7 years ago
- Comments:10 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
#550 @pal5hahnair apparently solved this issue.