I have a curious problem with creating a tweet with a jpeg image, using twurl i get this.
twurl -H upload.twitter.com "/1.1/media/upload.json" -f ~/Pictures/original.jpeg -F media -X POST
{"media_id":907964867277193217,"media_id_string":"907964867277193217","size":1997218,"expires_after_secs":86400,"image":{"image_type":"image\/jpeg","w":7360,"h":4912}
twurl "/1.1/statuses/update.json" -d "media_ids=907964867277193217&status=Test"
{"errors":[{"message":"Internal error","code":131}]}
The image is accepted for upload, but fails when creating the tweet.
However if I open the file in an editor and save it again with a jpeg quality setting of 100 (it is 75 in the original), then it works:
twurl -H upload.twitter.com "/1.1/media/upload.json" -f ~/Pictures/copy_100.jpeg -F media -X POST
{"media_id":907965824824209408,"media_id_string":"907965824824209408","size":5240327,"expires_after_secs":86400,"image":{"image_type":"image\/jpeg","w":7360,"h":4912}}
twurl "/1.1/statuses/update.json" -d "media_ids=907965824824209408&status=Test"
{"created_at":"Wed Sep 13 13:55:32 +0000 2017","id":907965975680753664,"id_str":"907965975680753664","text":"Test https:\/\/t.co\/BCxgOWvBbo","truncated":false,"entities":{"hashtags":[],"symbols":[],"user_mentions":[],"urls":[],"media":[{"id":907965824824209408,"id_str":"907965824824209408","indices":[5,28],"media_url":"http:\/\/pbs.twimg.com\/media\/DJm-G2jXcAAOts4.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/DJm-G2jXcAAOts4.jpg","url":"https:\/\/t.co\/BCxgOWvBbo","display_url":"pic.twitter.com\/BCxgOWvBbo","expanded_url":"https:\/\/twitter.com\/grums\/status\/907965975680753664\/photo\/1","type":"photo","sizes":{"medium":{"w":1200,"h":801,"resize":"fit"},"small":{"w":680,"h":454,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"large":{"w":2048,"h":1367,"resize":"fit"}}}]},"extended_entities":{"media":[{"id":907965824824209408,"id_str":"907965824824209408","indices":[5,28],"media_url":"http:\/\/pbs.twimg.com\/media\/DJm-G2jXcAAOts4.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/DJm-G2jXcAAOts4.jpg","url":"https:\/\/t.co\/BCxgOWvBbo","display_url":"pic.twitter.com\/BCxgOWvBbo","expanded_url":"https:\/\/twitter.com\/grums\/status\/907965975680753664\/photo\/1","type":"photo","sizes":{"medium":{"w":1200,"h":801,"resize":"fit"},"small":{"w":680,"h":454,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"large":{"w":2048,"h":1367,"resize":"fit"}}}]},"source":"\u003ca href=\"https:\/\/www.falcon.io\" rel=\"nofollow\"\u003efalcon audience importer\u003c\/a\u003e","in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":4360291,"id_str":"4360291","name":"Nikolaj Olsen","screen_name":"grums","location":"Copenhagen, Denmark","description":"The entity formerly known as tebro","url":"http:\/\/t.co\/8JPYHN1KCK","entities":{"url":{"urls":[{"url":"http:\/\/t.co\/8JPYHN1KCK","expanded_url":"http:\/\/www.ordinarypeople.dk\/","display_url":"ordinarypeople.dk","indices":[0,22]}]},"description":{"urls":[]}},"protected":false,"followers_count":39,"friends_count":127,"listed_count":3,"created_at":"Thu Apr 12 14:23:50 +0000 2007","favourites_count":1,"utc_offset":7200,"time_zone":"Copenhagen","geo_enabled":true,"verified":false,"statuses_count":462,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"C6E2EE","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/16663332\/twitter_bg.jpg","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/16663332\/twitter_bg.jpg","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/250018605\/twitter_pic_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/250018605\/twitter_pic_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/4360291\/1409601459","profile_link_color":"1F97C7","profile_sidebar_border_color":"C6E2EE","profile_sidebar_fill_color":"DAECF4","profile_text_color":"663B12","profile_use_background_image":true,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false,"translator_type":"none"},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":0,"favorite_count":0,"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"}
Save the image with any other quality setting than 100 will fail with
{"errors":[{"message":"Internal error","code":131}]}
Tweeting the same image (regardless of jpeg quality settings) in a browser works as expected.