MG 2.2 Max file size limit ignored?

snoopy5

Well-known member
Hi,

I just installed MG on my forum. I set different file size upload limits for the different user groups.

Registered users have in ACP/user group settings

  • Maximum file size (MB): 1 MB and
  • Maximum image widthxheight: 1600x1600 pixel.
  • Maximum allowed storage (MB): 20 MB.

But if I test this now with a test account, the user can upload nevertheless an image of 5.2 MB file size. How is that possible?
 
The image is probably less than 1MB after it has been uploaded if the server resizes it.

5.2MB is quite large for a file, so I'm guessing its dimensions exceed the maximum you have set of 1600x1600 pixels.

After it has been resized to be within the 1600x1600 pixel maximum, the resulting file size is probably smaller than 1MB so it is allowed.
 
After it has been resized to be within the 1600x1600 pixel maximum, the resulting file size is probably smaller than 1MB so it is allowed.

That would mean that the file size restrictions of XF are handled differently than the file size restrictions for MG. That is not really good.

If the same image would have been uploaded in the forum, XF would not even try to resize, it would reject it completely, because the file size is too big.

It is difficult to sell premium memberships, if it is just by accident whether a to large file is rejected or not. Depending on the image and its compression ability.

How can I make it work in MG like in XF? File size >1Mb shall be rejected and not at all reduced for that user group only
 
I have to check that again with XF and come back to this.

Back to MG:

If I click on the image within MG, it sais on the right side metadata:

File size: 5.2 MB
Dimensions: 4160px x 6240px

These are the specifications before the upload then, as far as I understand it, which leads to confusion to see that in the album.

If I go in ACP/attachment browser, I see the same image there listed with

470KB
1067x1600 pixel


Why does MG show the wrong data in the gallery for the user? How can I change this to the real data?
 
The metadata is captured before the image is manipulated. Resizing the image removes the metadata so we capture it before that. There's no way to change the data.
 
But in ACP it displays the correct data. It just need to take these data and display them there. This should be done in the next release. We will get hammered with these kind of questions, if the users are seeing this.

In the mean time, in which language file can I add then a hint, that these data are status quo before resizing/upload?
 
In the mean time, in which language file can I add then a hint, that these data are status quo before resizing/upload?
xfmg_exif.file_size

xfmg_exif.dimensions

Another question:

In which order does MG changes the images? First Pixel dimensions and then KB?

In my highest usergroup, I have for example no pixel restrictions for MG. Only file size limit of 3MB.

How does the software proceeds the image here?
 
and here is another problem:

A registered users with the above mentioned restrictions (1MB and 1600x1600) is able to upload that 5.2 MB file.

Premium user group member with restrictions of 3MB file size and unlimited pixel size can not upload the same image.

Error: file is too large.

How shall I explain that to my premium members?
 
It if the file exceeds the limit, and is not to be resized to smaller pixel dimensions, what is supposed to happen if not an error stating the file is too large?
 
After further tests, it is getting worse

It seems that

a) there must be always a pixel size restriction, otherwise it will always block the image (MG does not compress)
-> the option in the ACP/user group/Maximum image width&height "unlimited" is therefore worthless

b) If I set a pixel size limit, which is only marginal below the real pixel size of the image, it will block also the image (again MG does not compress)

c) Only if I set in ACP a drastically smaller pixel size than the image has which will be uploaded, MG does compress

But I do not know beforehand, which images the users will upload. Every user will have different file sizes. This is gambling.

If the image of user is only slightly bigger than the setting, he gets an error, although MG should have downsized it. As soon as the user uses after that a smaller pixel version, it will be rejected again, because MG does not compress it since the pixel dimensions are "ok".

How do we resolve this problem now?

P.S. I use image magick, in case this is relevant.
 
Last edited:
a) there must be always a pixel size restriction, otherwise it will always block the image
No. An image is accepted if
  • Its filesize is less than or equal the maximum allowed filesize and its dimensions are less than or equal the maximum allowed dimensions.
    If no maximum width / height is defined the width / height of the image doesn't matter.
  • At least one of its dimensions is larger than the maximum allowed value, the image can be resized and the filesize after resize is less than or equal the maximum allowed filesize
    If no maximum allowed filesize is defined and the image can be resized the filesize after resize doesn't matter.
b) If I set a pixel size limit, which is only marginal below the real pixel size of the image, it will block also the image (again MG does not compress)
Not necessarily, but this can happen.
Lets' say the maximum allowed size is 6000x4000 pixel with a maximum filesize of 3 MB.
You are trying to upload a a 6001x4001 JPEG @ 90% that has a filesize of 5 MB.
If this JPEG is resized to 6000x4000 and saved @ 85% (this is the setting XenForo uses) it is somewhat unlikely that resized file will be <= 3 MB.

As soon as the user uses after that a smaller pixel version, it will be rejected again, because MG does not compress it since the pixel dimensions are "ok".
How do we resolve this problem now?
Yes, XenForo will not try to re-save and image if the dimensions are within the limit but the filesize does exceed the maximum allowed filesize limit.
While re-saving the file without resizing it might reduce the filesize in some cases, it surely wouldn't work in all cases.

Basically you've got two options:
  • Do not set maximum width / height and allow a large filesize
  • Allow only a small filesize and set appropriate maximum width / height
 
Last edited:
Back
Top Bottom