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

media too large #76

Open
rillian opened this issue Aug 19, 2015 · 7 comments
Open

media too large #76

rillian opened this issue Aug 19, 2015 · 7 comments

Comments

@rillian
Copy link

rillian commented Aug 19, 2015

I tried sharing a photo from the Firefox OS gallery app, but the post fails with

Error: one or more of the uploaded media is too large.

This is on a Sony Z3c, so it's a 4.4 MB 3936x5248 pixel image.

Doesn't happen with the twitter.com website it with the twidere android client on the same hardware.

Does twitter require downsampling the image?

@rillian
Copy link
Author

rillian commented Aug 19, 2015

"Media uploads for images are limited to 5MB in file size, and for videos are limited to 15MB. For chunked uploads, the maximum chunk size is 5MB." -- https://dev.twitter.com/rest/reference/post/media/upload

So macaw might be over the limit if it's sending base64 media_data.

@minego
Copy link
Owner

minego commented Aug 19, 2015

The wording of
https://dev.twitter.com/rest/reference/post/media/upload-chunked implies
that even a chunked image has a total maximum size of 5MB. I'm not sure
if I am reading that correctly though.

On 08/19/15 15:50, Ralph Giles wrote:

"Media uploads for images are limited to 5MB in file size, and for
videos are limited to 15MB. For chunked uploads, the maximum chunk size
is 5MB." -- https://dev.twitter.com/rest/reference/post/media/upload

So macaw might be over the limit if it's sending base64 |media_data| and
not chunking.


Reply to this email directly or view it on GitHub
#76 (comment).

@rillian
Copy link
Author

rillian commented Aug 19, 2015

Yes, I think you're right. Presumedly that's per-image. Maybe 5MB < 4.4MB because of inconsistent units?

@minego
Copy link
Owner

minego commented Aug 19, 2015

On 08/19/15 15:57, Ralph Giles wrote:

Yes, I think you're right. Presumedly that's per-image. Maybe 5MB <
4.4MB because of inconsistent units?


Reply to this email directly or view it on GitHub
#76 (comment).

That seems likely to me.

I suspect that twitter wants the client to resize the image before
sending it. I'm not sure how I can do that in this case. This may take
some experimentation.

@rillian
Copy link
Author

rillian commented Aug 20, 2015

I suppose you can draw it into a hidden canvas element? How does the thumbnailing work?

https://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/

canvas.toBlob() looks like the most efficient interface for getting the new jpeg data for upload.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob

@minego
Copy link
Owner

minego commented Aug 20, 2015

That is basically what the thumbnail does. That is a possibility but it
doesn't give me a great deal of control over the final size.
On Aug 20, 2015 7:53 AM, "Ralph Giles" notifications@github.com wrote:

I suppose you can draw it into a hidden canvas element? How does the
thumbnailing work?

https://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/

canvas.toBlob() looks like the most efficient interface for getting the
new jpeg data for upload.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob


Reply to this email directly or view it on GitHub
#76 (comment).

@rillian
Copy link
Author

rillian commented Aug 20, 2015

Media in my timeline on the website is all scaled to 600px width. So if you downsample to 1280 (or even 1920) as a maximum dimension it should be considerably smaller that 5MB as a jpeg and still display with reasonable quality.

Maybe do a loop to explore a few options. Try converting png to png, jpeg to jpeg. If the result is too large (Blob.size) try again with a lower jpeg quality, or with jpeg instead of png, or halve the dimensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants