I have a server action for image resize. If I upload a 6000 px width image and try to resize to 2000 I get error 500 on server.
Any idea how to solve or validate max image width to upload?
I have a server action for image resize. If I upload a 6000 px width image and try to resize to 2000 I get error 500 on server.
Any idea how to solve or validate max image width to upload?
So what is the exact error?
Please check the error message as explained here:
Are you using Node or PHP? I know Apache for PHP has a max upload filesize in the php,ini file. Maybe your original is too large? If you try with a smaller source does it upload fine?
Just read your post closer.
It is my bet you are exceeding the server file upload limit as I suggested. If you are using PHP it is an easy fix. By default apache sets max file upload to 2MB. You can adjust that in the .htaccess file.
## Start Max File Upload Size
php_value upload_max_filesize 10M
php_value post_max_size 11M
I looked up the method for Node on ChatGPT but it was way over my head.
I am using php but is not the file weight is the image size 6000px * 3000px
{
"code": 0,
"file": "\/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/core\/Path.php",
"line": 50,
"message": "Trying to access array offset on value of type null",
"trace": "#0 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/core\/Path.php(50): exception_error_handler(8, 'Trying to acces...', '\/Volumes\/Bycom\/...', 50, Array)\n#1 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/modules\/image.php(32): lib\\core\\Path::toSystemPath(NULL)\n#2 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(206): modules\\image->load(Object(stdClass), 'picTextImage', Array)\n#3 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(178): lib\\App->execSteps(Object(stdClass))\n#4 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(146): lib\\App->execSteps(Array)\n#5 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/modules\/core.php(100): lib\\App->exec(Object(stdClass), true)\n#6 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(206): modules\\core->condition(Object(stdClass), '', NULL)\n#7 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(146): lib\\App->execSteps(Object(stdClass))\n#8 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/modules\/core.php(100): lib\\App->exec(Object(stdClass), true)\n#9 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(206): modules\\core->condition(Object(stdClass), '', NULL)\n#10 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(146): lib\\App->execSteps(Object(stdClass))\n#11 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/modules\/core.php(102): lib\\App->exec(Object(stdClass), true)\n#12 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(206): modules\\core->condition(Object(stdClass), '', NULL)\n#13 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(146): lib\\App->execSteps(Object(stdClass))\n#14 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/modules\/core.php(102): lib\\App->exec(Object(stdClass), true)\n#15 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(206): modules\\core->condition(Object(stdClass), '', NULL)\n#16 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(146): lib\\App->execSteps(Object(stdClass))\n#17 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/modules\/core.php(102): lib\\App->exec(Object(stdClass), true)\n#18 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(206): modules\\core->condition(Object(stdClass), '', NULL)\n#19 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(146): lib\\App->execSteps(Object(stdClass))\n#20 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/modules\/core.php(102): lib\\App->exec(Object(stdClass), true)\n#21 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(206): modules\\core->condition(Object(stdClass), '', NULL)\n#22 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(146): lib\\App->execSteps(Object(stdClass))\n#23 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/modules\/core.php(102): lib\\App->exec(Object(stdClass), true)\n#24 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(206): modules\\core->condition(Object(stdClass), '', NULL)\n#25 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(178): lib\\App->execSteps(Object(stdClass))\n#26 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(146): lib\\App->execSteps(Array)\n#27 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(135): lib\\App->exec(Object(stdClass), false)\n#28 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnectLib\/lib\/App.php(113): lib\\App->exec(Object(stdClass))\n#29 \/Volumes\/Bycom\/Websites\/DreamhomesWappler\/www\/dmxConnect\/api\/admin\/projectModules.php(8): lib\\App->define(Object(stdClass))\n#30 {main}"
}<br/><b>Fatal error</b>: Uncaught ErrorException: imagedestroy() expects parameter 1 to be resource, null given in /Volumes/Bycom/Websites/DreamhomesWappler/www/dmxConnectLib/lib/image/Processor.php: 25 Stack trace: #0[
internal function
]: exception_error_handler(2,
'imagedestroy() ...',
'/Volumes/Bycom/...',
25,
Array)#1/Volumes/Bycom/Websites/DreamhomesWappler/www/dmxConnectLib/lib/image/Processor.php(25): imagedestroy(NULL)#2[
internal function
]: lib\image\Processor->__destruct()#3{
main
}thrown in<b>/Volumes/Bycom/Websites/DreamhomesWappler/www/dmxConnectLib/lib/image/Processor.php</b> on line <b>25</b><br/>
Pixel size shouldn't matter. File size does.
If I PRE-resize the image to 2000px width It work perfect.
Thats what I think but it dont work. See videos posted.
Trying to access array offset on value of type null
This may suggest that it is not stored due to it's size (was not uploaded or failed to complete), and as Brad points out your PHP settings may be the issue? If the image is larger than the specified accepted size your path will be null and no image exists, hence the error message above.
That's because you reduced the file size when you resized it.
Is a little bigger but not 10 mb
One is 533 KB and the other is only 3.3 mb and I have a validation that dont allow more than 5 mb.
And the 3.3 MB probably won't work as it is over the 2MB default apache setting.
Is any way to increase it?
You could quickly try adding:
php_value post_max_size 100M
php_value upload_max_filesize 30M
To your .htaccess file and see if this resolves it if you don't want to mess around with your php.ini file or can't access it for some reason or other...
SORRY BRAD realised I just said exactly what you suggested
I added like this:
## Wappler routing
RewriteEngine On
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?(?:/)?$ index.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?admin/project_list(?:/)?$ admin/project_list.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?admin/project_detail/([^/]+?)(?:/)?$ admin/project_detail.php?URL_project=$1 [QSA,NC,L]
## End Wappler routing
## Start Max File Upload Size
php_value upload_max_filesize 10M
php_value post_max_size 11M
But still not working. I am using WAPPLER php internal server.
Does it work on your remote server?
May I make a suggestion... If you plan to upload many images in the future consider using S3 to store them away from your server. Wappler has everything built in for what you need to do.
Havent tested now is on production and on use. I will try later.
It is worth doing this now as that is the most important environment. You may find it works straight out of the box Juan Pablo.