Is there a file size limit on the Image Resizing tool?

I am uploading image files to a gallery and creating a resized thumbnail (h = 150px). It works perfects on image files under 2 MB in size, but fails on files larger than this. The original file uploads without issue, the largest I’ve tried is 3.4 MB, the action fails on the “resize Image” command.

Can I increase the workable file size?

image

There are no limits in Wappler, the limits are set on your server.
What server model are you using?

Thanks Teodor, I assumed that was the case. My server is a Plesk running PHP 7.2.34

What memory settings should I look for?

Check the upload_max_filesize and post_max_size properties in your server configuration / php.ini

upload_max_filesize = 16M
post_max_size = 8M

You’ll need to adjust your memory_limit too. We had similar issues with multiple upload Dropzones (in a multi-insert step). Increased to 768mb and now munches through the uploads without issue. Bare in mind if you have multiple users uploading at the same time you may well wish to increase this limit even further, obviously depending on your site activity…

2 Likes

Thanks Dave,

I have the memory_limit set to 128M (which is the max available setting.)

May find this helpful, can also do this via your .htaccess file if you can’t do it from the server control panel:

What's the exact error returned by your server when running the server action?

2 Likes

Dave,

I was able to increase the memory_limit to 256M (I had only tried the dropdown values, but I could use a large value simply by keying it in). And I was able to successfully load (and resize) the larger image file.

Note: I’ll try an even larger value next, but thought I’d grow it in steps.

2 Likes

Thanks Teodor,

I will try to take advantage of those reports in the future.

That’s great. Yes little steps. No giant leaps. Hehehe…

:smiley:

1 Like

The filesize doesn’t say anything about the size a image takes in memory. The file gets stored uncompressed in memory, standard formula is width * height * 4 (every pixel takes 4bits (RGBA) in memory). You need more then just the image data if you are going to manipulate it.

3 Likes

Thanks Patrick.

I increased the memory to 512MB and have been able to process the images I intended. (Also set a Max file size attribute to remind me when I forget!)

I was surprised how much memory was needed to resize images and used this as a guide, in case it’s useful:

<?php
// https://www.php.net/manual/en/function.imagecreatefromjpeg.php#60241
// calculates required memory_limit setting with imagecreatefromjpeg function (eg for reaizing images)
// test image entered below

$imageInfo = getimagesize('images/myimage.jpg'); 
$memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $imageInfo['channels'] / 8 + Pow(2,16)) * 1.65); 
echo $memoryNeeded = 2241153200 ; 
echo '<br>' ;
echo number_format($memoryNeeded / 1073741824, 2) . ' GB' ;
?>
1 Like