Getting error : Image file size must be <= 5242880 bytes, while sharing gif image on twitter


#1

I’m trying to share gif image (of size 5.2MB ) on twitter but it is throwing {“errors”:[{“code”:324,“message”:“Image file size must be <= 5242880 bytes”}]}. Image url : https://storage.googleapis.com/gweb-uniblog-publish-prod/original_images/NLQA-Blog_1_1_KauuCTQ.gif.

As per document we can share gif images of size <=15 mb.
What could be the reason?


#2

How are you trying to upload this - are you using the chunked upload method?

I’ve just successfully uploaded your file using the large video upload sample (changing out tweet_video for tweet_gif). Here’s the output (minus the final Tweet).

INIT
Media ID: 910887539497517057
APPEND
4194304 of 5485882 bytes uploaded
APPEND
5485882 of 5485882 bytes uploaded
Upload chunks complete.
FINALIZE
{'media_id': 910887539497517057, 'media_id_string': '910887539497517057', 'media_key': '16_910887539497517057', 'size': 5485882, 'expires_after_secs': 86400, 'processing_info': {'state': 'pending', 'check_after_secs': 1}}
{'state': 'pending', 'check_after_secs': 1}
Media processing status is pending
Checking after 1 seconds
STATUS
{'state': 'in_progress', 'check_after_secs': 1, 'progress_percent': 5}
Media processing status is in_progress
Checking after 1 seconds
STATUS
{'state': 'succeeded', 'progress_percent': 100}
Media processing status is succeeded

I suspect the problem might be that you’re trying to do it in a single upload rather than breaking it into smaller chunks.


#3

Can you share the response of final tweet. I have uploaded the image successfully while sharing this image only got that error.


#4

Sure - the final line of the output from the upload script was this (a Tweet object - omitted in my previous post for brevity)

{'created_at': 'Thu Sep 21 15:24:56 +0000 2017', 'id': 910887575686205440, 'id_str': '910887575686205440', 'text': 'I just uploaded a video with the @TwitterAPI. https://t.co/6nU3pMQ1Ax', 'truncated': False, 'entities': {'hashtags': [], 'symbols': [], 'user_mentions': [{'screen_name': 'TwitterAPI', 'name': 'Twitter API', 'id': 6253282, 'id_str': '6253282', 'indices': [33, 44]}], 'urls': [], 'media': [{'id': 910887539497517057, 'id_str': '910887539497517057', 'indices': [46, 69], 'media_url': 'http://pbs.twimg.com/tweet_video_thumb/DKQfZB4UQAE2KWQ.jpg', 'media_url_https': 'https://pbs.twimg.com/tweet_video_thumb/DKQfZB4UQAE2KWQ.jpg', 'url': 'https://t.co/6nU3pMQ1Ax', 'display_url': 'pic.twitter.com/6nU3pMQ1Ax', 'expanded_url': 'https://twitter.com/MrBonesDroid/status/910887575686205440/photo/1', 'type': 'photo', 'sizes': {'large': {'w': 1000, 'h': 500, 'resize': 'fit'}, 'thumb': {'w': 150, 'h': 150, 'resize': 'crop'}, 'medium': {'w': 600, 'h': 300, 'resize': 'fit'}, 'small': {'w': 340, 'h': 170, 'resize': 'fit'}}}]}, 'extended_entities': {'media': [{'id': 910887539497517057, 'id_str': '910887539497517057', 'indices': [46, 69], 'media_url': 'http://pbs.twimg.com/tweet_video_thumb/DKQfZB4UQAE2KWQ.jpg', 'media_url_https': 'https://pbs.twimg.com/tweet_video_thumb/DKQfZB4UQAE2KWQ.jpg', 'url': 'https://t.co/6nU3pMQ1Ax', 'display_url': 'pic.twitter.com/6nU3pMQ1Ax', 'expanded_url': 'https://twitter.com/MrBonesDroid/status/910887575686205440/photo/1', 'type': 'animated_gif', 'sizes': {'large': {'w': 1000, 'h': 500, 'resize': 'fit'}, 'thumb': {'w': 150, 'h': 150, 'resize': 'crop'}, 'medium': {'w': 600, 'h': 300, 'resize': 'fit'}, 'small': {'w': 340, 'h': 170, 'resize': 'fit'}}, 'video_info': {'aspect_ratio': [2, 1], 'variants': [{'bitrate': 0, 'content_type': 'video/mp4', 'url': 'https://video.twimg.com/tweet_video/DKQfZB4UQAE2KWQ.mp4'}]}}]}, 'source': '<a href="http://andypiper.co.uk" rel="nofollow">bonesTwurl</a>', 'in_reply_to_status_id': None, 'in_reply_to_status_id_str': None, 'in_reply_to_user_id': None, 'in_reply_to_user_id_str': None, 'in_reply_to_screen_name': None, 'user': {'id': 4449621923, 'id_str': '4449621923', 'name': 'Mr Bones', 'screen_name': 'MrBonesDroid', 'location': '', 'description': '', 'url': None, 'entities': {'description': {'urls': []}}, 'protected': True, 'followers_count': 8, 'friends_count': 9, 'listed_count': 0, 'created_at': 'Fri Dec 11 15:18:02 +0000 2015', 'favourites_count': 25, 'utc_offset': -25200, 'time_zone': 'Pacific Time (US & Canada)', 'geo_enabled': False, 'verified': False, 'statuses_count': 119, 'lang': 'en-gb', 'contributors_enabled': False, 'is_translator': False, 'is_translation_enabled': False, 'profile_background_color': 'F5F8FA', 'profile_background_image_url': None, 'profile_background_image_url_https': None, 'profile_background_tile': False, 'profile_image_url': 'http://pbs.twimg.com/profile_images/907222562060619777/yaDsyBcT_normal.jpg', 'profile_image_url_https': 'https://pbs.twimg.com/profile_images/907222562060619777/yaDsyBcT_normal.jpg', 'profile_link_color': '1DA1F2', 'profile_sidebar_border_color': 'C0DEED', 'profile_sidebar_fill_color': 'DDEEF6', 'profile_text_color': '333333', 'profile_use_background_image': True, 'has_extended_profile': False, 'default_profile': True, 'default_profile_image': False, 'following': False, 'follow_request_sent': False, 'notifications': False, 'translator_type': 'none'}, 'geo': None, 'coordinates': None, 'place': None, 'contributors': None, 'is_quote_status': False, 'retweet_count': 0, 'favorite_count': 0, 'favorited': False, 'retweeted': False, 'possibly_sensitive': False, 'lang': 'en'}


#5

In the response media_url should be gif right?


#6

No, it would be a jpg (thumbnail of the uploaded and transcoded gif)