Skip to content

Change media upload limits and remove client-side resizing#23726

Merged
Gargron merged 1 commit intomainfrom
feature-increase-media-limits
Mar 25, 2023
Merged

Change media upload limits and remove client-side resizing#23726
Gargron merged 1 commit intomainfrom
feature-increase-media-limits

Conversation

@Gargron
Copy link
Member

@Gargron Gargron commented Feb 19, 2023

For media attachments, the limits become:

  • Images:
    • Upload size: 10 MB to 16 MB
    • Target dimensions: Full HD to 4K
    • Processing limit: 4K to 8K
  • Videos:
    • Upload size: 40 MB to 99 MB
    • FPS limit: 60 FPS to 120 FPS
    • Processing limit: Full HD to 4K

For link preview cards, the limits become:

  • Upload size: 1 MB to 2 MB

Client-side resizing is removed to avoid low-quality output. The max. RAM usage of ImageMagick becomes 847 MB.


Fixes MAS-47

@Gargron Gargron force-pushed the feature-increase-media-limits branch 3 times, most recently from 163acaf to d25b6b5 Compare February 19, 2023 10:30
@renchap
Copy link
Member

renchap commented Feb 19, 2023

If this goes through, you can also remove the resize_image.js files and the exif-js JS dependency.

@tabletcorry
Copy link

Can the media resizing process forks be niced to keep them from swamping the system as heavily?

Larger media sounds great, but I already see occasional media cause massive CPU spikes on my personal instance. Communicating the low priority of conversion to the cpu scheduler would help a lot.

@ClearlyClaire
Copy link
Contributor

This will cause an increase in RAM, CPU, and storage usage on all servers, so we really need to be careful about such changes.

@ClearlyClaire
Copy link
Contributor

If this goes through, you can also remove the resize_image.js files and the exif-js JS dependency.

True, although we could use exif-js to provide alt-text-from-image-metadata functionality (could also be done server-side I guess but it makes more sense to me as a client-side feature)

@shleeable
Copy link
Contributor

shleeable commented Feb 20, 2023

Storage is cheap, so I'm fine with the increased image/movie size, but the effect Client-side resizing being removed will have on smaller instances needs to be considered.

I'd rather you set a standard and transcode on the iOS app for example to a known universal standard... Our CPUs are going to cry... but making 8 accounts and uploading a large 4K video will most than likely result in a DOS.

@anampses
Copy link

anampses commented Feb 20, 2023

This is a welcome change for art instances such as mine. However, I noticed that this upcoming change increases the max video resolution to 4K, but image resolution is increasing to only 2K for some reason. Is there a reason for this? Why would video media get to have more pixels when previously both video and images had the same FHD limit image format?

Ideally the image size should be bumped up to at least 4K, just like video. Having more pixels is important for artists since it is more common for images to be entirely graphical (eg illustrations, comics) than it is with videos which is usually captured.

Also, since there is no more client-side resizing, a higher pixel limit will keep the server's CPU/RAM usage down since the server won't have to do resizing of images as often.

@ClearlyClaire
Copy link
Contributor

Bumping the image pixel count limit is very RAM-costly due to the tools we use. Until we ditch ImageMagick, I don't think it's wise to increase the allowed input image pixel count at all. #23322 touches on this and actually allows larger output images than the current PR (that means a potential storage cost increase, but not a RAM or CPU one unlike the current PR)

@rrgeorge
Copy link
Contributor

rrgeorge commented Mar 9, 2023

I think that the max size should only be 100MB, as that’s the upload limit on some CDNs.

@Gargron Gargron force-pushed the feature-increase-media-limits branch from d25b6b5 to f5112bf Compare March 15, 2023 23:31
@Gargron
Copy link
Member Author

Gargron commented Mar 15, 2023

Changed video size limit to 99 MB, target dimensions for images to 4K (same as videos).

The changed image matrix limit means the max. ImageMagick memory usage will be about 847 MB.

@Gargron Gargron force-pushed the feature-increase-media-limits branch 2 times, most recently from 13bbdf9 to e9ede10 Compare March 16, 2023 21:00
Copy link

@WhiskeyOmega WhiskeyOmega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I suggest we include slightly higher vertical resolution to include DSLR images Aspect Ratios

app/models/concerns/attachmentable.rb
MAX_MATRIX_LIMIT = 33_177_600 # 7680x4913px or approx. 847MB in RAM

app/models/media_attachment.rb
original: {
pixels: 9_434_880, # 3840x2457px
file_geometry_parser: FastGeometryParser,
}.freeze,

For media attachments, the limits become:

- Images:
  - Upload size: 10 MB to 16 MB
  - Target dimensions: Full HD to 4K
  - Processing limit: 4K to 8K
- Videos:
  - Upload size: 40 MB to 99 MB
  - FPS limit: 60 FPS to 120 FPS
  - Processing limit: Full HD to 4K

For link preview cards, the limits become:

- Upload size: 1 MB to 2 MB

Client-side resizing is removed to avoid low-quality output
@Gargron Gargron force-pushed the feature-increase-media-limits branch from e9ede10 to 8bcc337 Compare March 25, 2023 08:45
@Gargron Gargron merged commit 9bda933 into main Mar 25, 2023
@Gargron Gargron deleted the feature-increase-media-limits branch March 25, 2023 09:00
noellabo pushed a commit to fedibird/mastodon that referenced this pull request Mar 26, 2023
neatchee added a commit to neatchee/mastodon that referenced this pull request Mar 27, 2023
jesseplusplus pushed a commit to jesseplusplus/decodon that referenced this pull request May 25, 2024
yuangezhizao added a commit to yuangezhizao/mastodon that referenced this pull request May 26, 2024
noellabo pushed a commit to fedibird/mastodon that referenced this pull request Sep 9, 2024
maa123 added a commit to maa123/mastodon that referenced this pull request Oct 26, 2024
@smiba
Copy link
Contributor

smiba commented Feb 3, 2025

I get occasional complaints from users about not being able to upload something because its resolution is too big.
Why was client sided resizing removed? Why not keep it even after increasing the resolution limit? Right now users are faced with an error, telling them something can't be uploaded and they'll have to figure out how to resize something themselves.

I understand javascript based image resizes are not as efficient nor as high quality but surely it's preferable over just showing the user an error? No other platform (Twitter or bsky) seems to have issues with the image a user complained about today (which is 5849x5944) which downgrades their experience using Mastodon

yuangezhizao added a commit to yuangezhizao/mastodon that referenced this pull request May 26, 2025
yuangezhizao added a commit to yuangezhizao/mastodon that referenced this pull request May 26, 2025
yuangezhizao added a commit to yuangezhizao/mastodon that referenced this pull request Jul 9, 2025
yuangezhizao added a commit to yuangezhizao/mastodon that referenced this pull request Jul 28, 2025
参照:mastodon#23726

(cherry picked from commit 9817d2a)
(cherry picked from commit e69c3a9)
(cherry picked from commit 41df02b)
yuangezhizao added a commit to yuangezhizao/mastodon that referenced this pull request Aug 23, 2025
参照:mastodon#23726

(cherry picked from commit 9817d2a)
(cherry picked from commit e69c3a9)
(cherry picked from commit 41df02b)
(cherry picked from commit eaed58e)
yuangezhizao added a commit to yuangezhizao/mastodon that referenced this pull request Nov 4, 2025
参照:mastodon#23726

(cherry picked from commit 9817d2a)
(cherry picked from commit e69c3a9)
(cherry picked from commit 41df02b)
(cherry picked from commit eaed58e)
(cherry picked from commit e1bb5d5)
yuangezhizao added a commit to yuangezhizao/mastodon that referenced this pull request Nov 4, 2025
参照:mastodon#23726

(cherry picked from commit 9817d2a)
(cherry picked from commit e69c3a9)
(cherry picked from commit 41df02b)
(cherry picked from commit eaed58e)
(cherry picked from commit e1bb5d5)
(cherry picked from commit 8681df6)
yuangezhizao added a commit to yuangezhizao/mastodon that referenced this pull request Nov 4, 2025
参照:mastodon#23726

(cherry picked from commit 9817d2a)
(cherry picked from commit e69c3a9)
(cherry picked from commit 41df02b)
(cherry picked from commit eaed58e)
(cherry picked from commit e1bb5d5)
(cherry picked from commit 8681df6)
(cherry picked from commit c18b9d4)
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

Successfully merging this pull request may close these issues.