major-mayer / imageconverter

A simple Nextcloud app to convert HEIC/ HEIF images to JPEG
GNU Affero General Public License v3.0
21 stars 2 forks source link

An Erorr Occured when convert a picture #2

Closed aquliu closed 3 years ago

aquliu commented 4 years ago

when I convert a heic to jpeg,It report An Erorr Occured!

the log is as below:

Exception: Too few arguments to function OC\Files\Storage\Wrapper\Wrapper::file_put_contents(), 1 passed in /var/www/nextcloud/lib/private/Files/View.php on line 1161 and exactly 2 expected /var/www/nextcloud/lib/private/AppFramework/App.php - line 152:

OC\AppFramework\Http\Dispatcher->dispatch(OCA\ImageCon ... {}, "convertImage")

/var/www/nextcloud/lib/private/Route/Router.php - line 308:

OC\AppFramework\App::main("OCA\ImageC ... r", "convertImage", OC\AppFramew ... {}, { action: nu ... "})

/var/www/nextcloud/lib/base.php - line 1009:

OC\Route\Router->match("/apps/imageconverter/convert")

/var/www/nextcloud/index.php - line 37:

OC::handleRequest()

The Reason is:ArgumentCountError: Too few arguments to function OC\Files\Storage\Wrapper\Wrapper::file_put_contents(), 1 passed in /var/www/nextcloud/lib/private/Files/View.php on line 1161 and exactly 2 expected /var/www/nextcloud/lib/private/Files/View.php - line 1161:

OC\Files\Storage\Wrapper\Wrapper->file_put_contents("files/照片 20 ... g")

/var/www/nextcloud/lib/private/Files/View.php - line 696:

OC\Files\View->basicOperation("file_put_contents", "/liushui/fi ... g", [ "update","write"], null)

/var/www/nextcloud/lib/private/Files/Node/File.php - line 72:

OC\Files\View->file_put_contents("/liushui/fi ... g", null)

/var/www/nextcloud/apps/imageconverter/lib/Storage/ConvertStorage.php - line 62:

OC\Files\Node\File->putContent(null)

/var/www/nextcloud/apps/imageconverter/lib/Controller/ConvertController.php - line 59:

OCA\ImageConverter\Storage\ConvertStorage->saveNewImage(2244, "照片 20-03-01 21-41-38 0332.jpg", null)

/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 169:

OCA\ImageConverter\Controller\ConvertController->convertImage("照片 20-03-01 ... c", 2244, 100)

/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 100:

OC\AppFramework\Http\Dispatcher->executeController(OCA\ImageCon ... {}, "convertImage")

/var/www/nextcloud/lib/private/AppFramework/App.php - line 152:

OC\AppFramework\Http\Dispatcher->dispatch(OCA\ImageCon ... {}, "convertImage")

/var/www/nextcloud/lib/private/Route/Router.php - line 308:

OC\AppFramework\App::main("OCA\ImageC ... r", "convertImage", OC\AppFramew ... {}, { action: nu ... "})

/var/www/nextcloud/lib/base.php - line 1009:

OC\Route\Router->match("/apps/imageconverter/convert")

/var/www/nextcloud/index.php - line 37:

OC::handleRequest()_

Have any idea what should I do? Thx!

By the way,the Nextcloud cannot show the heic preview either,but my ImageMagick work works well when I tried to convert .heic to .jpeg in commond line.the php-imagick also installed but I don't know if it works well.

major-mayer commented 3 years ago

Hi sorry for the long time to respond, I hadn't had a Nextcloud dev instance running on my new PC so i couldn't elaborate what went wrong here. The conversion crashed when the ImageConverter tried to save the new file. I'm not exactly sure, but i think the reason for that is, that the PHP function file_put_contents() which is wrapped by OCP\Files\Fille->putContent() expects 2 arguments and only received one as it can be seen here:

ArgumentCountError: Too few arguments to function OC\Files\Storage\Wrapper\Wrapper::file_put_contents(), 1 passed in /var/www/nextcloud/lib/private/Files/View.php on line 1161 and exactly 2 expected

The first argument is the filepath, which I think was given, the second is the actual content of the file (so the converted image blob). This one seemed to be missing.

So to conclude I think the image couldn't be saved because it simply was not converted in the first place. This is also supported by the fact that your Nextcloud instance does not create HEIC -> JPEG previews at all.

Please execute php -r 'phpinfo();' | grep HEIC on your server as described in linked article from the Readme. If it's not printing anything, either your ImageMagick installation is not complied with HEIC support or something (which you say isn't the case) or PHP-Imagick is not installed (double check this with php -m). Best wishes

major-mayer commented 3 years ago

Close this because it seems stale