XF 2.1 Max image dimensions and max file size.

rfc0001

Well-known member
I'm confused. I always though max image dimentions was the size images were automatically resized to as long as the image is < max file size. I know I've uploaded images larger than these dimensions which have been resized. However, now I'm seeing errors where Xenforo says an image exceeds the max file size when it actually doesn't (max file attachment size is 25MB and images are 8 and 10MB). So, what gives?
 
Getting error "The uploaded file is too large". Get same error on test forum here. Files is 10,797,147 bytes - 8618 x 3670 pixels.
Maximum attachment file size is set to 25,600KB.
 
There's a hard limit on what can be resized and it defaults to 20 megapixels. An image which is 8618 x 3670 is a fairly whopping ~32 megapixels.

Certainly, if PHP tries to resize an image of those dimensions on some smaller servers, it would just cause an ugly out of memory error.

But it is configurable by adding the following to src/config.php:
PHP:
$config['maxImageResizePixelCount'] = 20000000;
20000000 is the default value. For you to be able to upload that image, you'd likely need to increase it to 32000000 or even 40000000 if you envisage images of that size being uploaded frequently (gives a bit of breathing space for even larger images to be uploaded).

Once you have increased that limit, you will need to test to ensure there are no adverse effects, such as the aforementioned out of memory errors. If there are, you would need to have the memory_limit in PHP increased (depending on server hardware, you may even need a physical RAM upgrade to handle it).
 
Thanks for the explanation...would be nice if this setting were configurable in ACP since you can configure max attachment file size, but not max megapixels which effectively is the constraint for images, not file size.
 
While I somewhat agree, as it is something I have considered previously, the significant thing is that this is potentially a feature breaking value - some admins could set this higher not appreciating the impact and cause performance issues.

However it’s also true that the same value has been in place as the default since 2010 and server capabilities are obviously somewhat higher since then but that’s not a safe assumption for all customers.
 
One idea - much like max image file size is contrained by PHP settings for max filesize, you could make the max megapixels contrained by the PHP memory_limit (e.g. 5% of memory limit, resulting in 25MP for 512M memory, 50MP for 1024M memory, 100MP for 2048M memory).
 
Also, the error messages could be updated to be more descriptive - e.g. maximum image size (height x width): 25 megapixels. Maximum attachment size: 10 MB.

By the way, when does the "The uploaded file is too large for the server to process." error occur vs. "The uploaded file is too large."? Thanks.
 
Top Bottom