Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publish to Twitter: if a photo size>5MB, shrink before posting #710

Closed
tantek opened this issue Dec 2, 2016 · 4 comments
Closed

publish to Twitter: if a photo size>5MB, shrink before posting #710

tantek opened this issue Dec 2, 2016 · 4 comments
Labels

Comments

@tantek
Copy link
Contributor

tantek commented Dec 2, 2016

Just as Bridgy Publish automatically shortens (ellipses) text content when posting to Twitter, it would be nice if Bridgy Publish could also detect when a photo being posted was too big for Twitter and resize it to be just under 5MB* (and then link to the original post for the full resolution version).

*Twitter photos must be <=5MB according to this actual error from Bridgy Publish logs:

2016-12-02 01:43:34.244510 W Error 400, response body: {"errors":[{"code":..."message":"Image file size must be <= 5242880 bytes"}]}

Photo being attempted to publish:

https://indieweb.org/images/f/fc/2016-335-hwc-sf.gif

@snarfed
Copy link
Owner

snarfed commented Dec 2, 2016

interesting idea! thanks for filing. resizing automatically seems like a minor liberty, but probably fine as long as we clearly document when and how it happens.

sounds like there's also some uncertainty around how Twitter handles animated gifs in particular? i guess that's orthogonal though. never mind!

the actual resizing would be straightforward, using either PIL or app engine's API: https://cloud.google.com/appengine/docs/python/images/

@snarfed snarfed added the publish label Dec 2, 2016
@snarfed
Copy link
Owner

snarfed commented Dec 2, 2016

re animated gifs, looks like they have extra limits on frames, etc:

https://dev.twitter.com/rest/media/uploading-media.html#gifrecs

... but 5MB limit is the same:

https://dev.twitter.com/rest/media/uploading-media.html#imagerecs

except maybe the limit is actually 3MB, not 5MB? from the link above:

The filesize limit above is enforced by the media upload endpoint. In addition, there is a separate product entity specific filesize limit which is applied when calling the Tweet creation (or similar) endpoints with media_id. For example, it is possible to upload a 5 MB image, but the Tweet creation requires images to be <= 3 MB. The filesize limit and other constraints may vary depending on the media_category parameter.

unfortunate, and confusing. @tantek this is begging for some empirical testing! eg can you POSSE a 4MB photo? :P

@snarfed
Copy link
Owner

snarfed commented Apr 1, 2019

related via @tantek: PNG compression:

Zegnat: A lot of graphics tools let you do that pretty easy too. I think both Pixelmator and Acorn (image editors for macOS I have used / use) allow me to export as indexed PNGs. Can give huge size savings.
[tantek]: I definitely prefer things I don't have to install
[tantek]: Wonder if such PNG compression would be worth adding / requesting in Bridgy Publish
[tantek]: though maybe it's more worth doing it all up front so your "original" copy is also smaller / loads faster

@snarfed
Copy link
Owner

snarfed commented Apr 6, 2023

Obsolete, Bridgy Twitter is dead. #1410 (comment)

@snarfed snarfed closed this as not planned Won't fix, can't repro, duplicate, stale Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 participants