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

[Glitch] Update client-side media resizing resolution to 3840x2160 to match model #2304

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Pokefan5
Copy link

Both mainline mastodon and the backend of glitch have increased the image size limit to 3840x2160.

Client-side resizing has been overlooked, causing images uploaded via the glitch flavour to be resized, when uploading via the vanilla flavour wouldn't resize the same images.

@WhiskeyOmega
Copy link

The whole thing at the time was completely rushed and my comments were ignored but to be fair this was before Claire was hired. It should have never been set at 3840x2160 or you're still compressing Pictures that are 2:3 or 4:3 right down with the current imagemagick. Instead it needs to be changed to 3840x2560 to compensate for Aspect Ratio. This has worked for months on my instance.

app/models/media_attachment.rb also needs an adjust at Line 45 to change it overall.

@ClearlyClaire
Copy link

or you're still compressing Pictures that are 2:3 or 4:3 right down with the current imagemagick

This PR is about client-side resizing of media before upload; the server side unconditionally processes local media with Imagemagick to strip metadata, the size limit or aspect ratio are not relevant to that.

@eobet
Copy link

eobet commented Apr 10, 2024

This is a one-line fix to bring glitch-soc in sync with Mastodon. Why hasn't it been merged yet?

@WhiskeyOmega
Copy link

WhiskeyOmega commented Apr 10, 2024

I did make a patch that also helps out on both glitch and Vanilla mastodon for it all but I was never sure how to explain it otherwise. Heres the glitch one.

diff --git a/app/javascript/flavours/glitch/utils/resize_image.js b/app/javascript/flavours/glitch/utils/resize_image.js
index e3d4e6a354..6d176f4b16 100644
--- a/app/javascript/flavours/glitch/utils/resize_image.js
+++ b/app/javascript/flavours/glitch/utils/resize_image.js
@@ -1,6 +1,6 @@
 import EXIF from 'exif-js';

-const MAX_IMAGE_PIXELS = 2073600; // 1920x1080px
+const MAX_IMAGE_PIXELS = 9830400; // 3840x2560px

 const _browser_quirks = {};

diff --git a/app/models/concerns/attachmentable.rb b/app/models/concerns/attachmentable.rb
index c0ee1bdce7..d78c2c1fa0 100644
--- a/app/models/concerns/attachmentable.rb
+++ b/app/models/concerns/attachmentable.rb
@@ -5,8 +5,8 @@ require 'mime/types/columnar'
 module Attachmentable
   extend ActiveSupport::Concern

-  MAX_MATRIX_LIMIT = 33_177_600 # 7680x4320px or approx. 847MB in RAM
-  GIF_MATRIX_LIMIT = 921_600    # 1280x720px
+  MAX_MATRIX_LIMIT = 70_000_000 # 10000x7000px or approx. 847MB in RAM
+  GIF_MATRIX_LIMIT = 14_822_400 # 3840x3860px

   # For some file extensions, there exist different content
   # type variants, and browsers often send the wrong one,
diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb
index 02d0f7b6a2..80c65be36d 100644
--- a/app/models/media_attachment.rb
+++ b/app/models/media_attachment.rb
@@ -39,12 +39,12 @@ class MediaAttachment < ApplicationRecord

   MAX_DESCRIPTION_LENGTH = 1_500

-  IMAGE_LIMIT = (ENV['MAX_IMAGE_SIZE'] || 16.megabytes).to_i
+  IMAGE_LIMIT = (ENV['MAX_IMAGE_SIZE'] || 99.megabytes).to_i
   VIDEO_LIMIT = (ENV['MAX_VIDEO_SIZE'] || 99.megabytes).to_i

   MAX_VIDEO_MATRIX_LIMIT = 8_294_400 # 3840x2160px
   MAX_VIDEO_FRAME_RATE   = 120
-  MAX_VIDEO_FRAMES       = 36_000 # Approx. 5 minutes at 120 fps
+  MAX_VIDEO_FRAMES       = 144_000 # Approx. 20 minutes at 120 fps

   IMAGE_FILE_EXTENSIONS = %w(.jpg .jpeg .png .gif .webp .heic .heif .avif).freeze
   VIDEO_FILE_EXTENSIONS = %w(.webm .mp4 .m4v .mov).freeze
@@ -70,7 +70,7 @@ class MediaAttachment < ApplicationRecord

   IMAGE_STYLES = {
     original: {
-      pixels: 8_294_400, # 3840x2160px
+      pixels: 9_830_400, # 3840x2560px
       file_geometry_parser: FastGeometryParser,
     }.freeze,

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.

4 participants