Closed ACiDGRiM closed 2 years ago
same error on nextcloud 22.1.1, even after a preview:repair the command preview:generate-all throw this trace :
`ValueError: imagecreatetruecolor(): Argument #1 ($width) must be greater than 0 in /var/www/nextcloud/lib/private/legacy/OC_Image.php:933 Stack trace:
This quick & dirty fix allow the generate-all process to continue if the image is broken :
nano +933 /var/www/nextcloud/lib/private/legacy/OC_Image.php
replace $process = imagecreatetruecolor($width, $height);
with this block :
if ($width > 0 and $height > 0){ $process = imagecreatetruecolor($width, $height); } else { $process = false; }
I'd like to try @Germwalker 's workaround but I'm with a snap installation and the file appears to be readonly :( Do I need to wait for the next release?
Workaround for snap installations:
edit the file /var/snap/nextcloud/current/extra-apps/previewgenerator/lib/Command/Generate.php and append an additional catch to the last function (parseFile)
catch(\Throwable $e){
$error = $e->getMessage();
$this->output->writeln("<error>${error}</error>");
}
this will allow the process to continue and show a red error in console if you run the command with -vvv option Note: This last solution would work also in normal nextcloud installations if you find the correct extra-apps folder
I have a lot of installer folders that contain image resources. frequently there are some images that are malformed, either intentionally or for other reasons. This causes the generate-all command to fail when it encounters this error.
Ideally the error would be thrown, but continue to process other images.
An unhandled exception has been thrown: ValueError: imagecreatetruecolor(): Argument #1 ($width) must be greater than 0 in /var/www/html/lib/private/legacy/OC_Image.php:933 Stack trace:
0 /var/www/html/lib/private/legacy/OC_Image.php(933): imagecreatetruecolor(0, 64)
1 /var/www/html/lib/private/legacy/OC_Image.php(905): OC_Image->preciseResizeNew(0, 64)
2 /var/www/html/lib/private/legacy/OC_Image.php(1155): OC_Image->resizeNew(64)
3 /var/www/html/lib/private/Preview/Generator.php(430): OC_Image->resizeCopy(64)
4 /var/www/html/lib/private/Preview/Generator.php(186): OC\Preview\Generator->generatePreview(Object(OC\Files\SimpleFS\SimpleFolder), Object(OCP\Image), 0, 64, false, 1, 400, '')
5 /var/www/html/lib/private/PreviewManager.php(204): OC\Preview\Generator->generatePreviews(Object(OC\Files\Node\File), Array, 'image/png')
6 /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php(203): OC\PreviewManager->generatePreviews(Object(OC\Files\Node\File), Array)
7 /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php(174): OCA\PreviewGenerator\Command\Generate->parseFile(Object(OC\Files\Node\File))
8 /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php(172): OCA\PreviewGenerator\Command\Generate->parseFolder(Object(OC\Files\Node\Folder))
9 /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php(172): OCA\PreviewGenerator\Command\Generate->parseFolder(Object(OC\Files\Node\Folder))
10 /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php(172): OCA\PreviewGenerator\Command\Generate->parseFolder(Object(OC\Files\Node\Folder))
11 /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php(172): OCA\PreviewGenerator\Command\Generate->parseFolder(Object(OC\Files\Node\Folder))
12 /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php(172): OCA\PreviewGenerator\Command\Generate->parseFolder(Object(OC\Files\Node\Folder))
13 /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php(172): OCA\PreviewGenerator\Command\Generate->parseFolder(Object(OC\Files\Node\Folder))
14 /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php(172): OCA\PreviewGenerator\Command\Generate->parseFolder(Object(OC\Files\Node\Folder))
15 /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php(155): OCA\PreviewGenerator\Command\Generate->parseFolder(Object(OC\Files\Node\Folder))
16 /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php(123): OCA\PreviewGenerator\Command\Generate->generateUserPreviews(Object(OC\User\User))
17 /var/www/html/lib/private/User/Manager.php(646): OCA\PreviewGenerator\Command\Generate->OCA\PreviewGenerator\Command{closure}(Object(OC\User\User))
18 /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php(124): OC\User\Manager->callForSeenUsers(Object(Closure))
19 /var/www/html/custom_apps/bookmarks/vendor/symfony/console/Command/Command.php(255): OCA\PreviewGenerator\Command\Generate->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
20 /var/www/html/custom_apps/bookmarks/vendor/symfony/console/Application.php(1009): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
21 /var/www/html/custom_apps/bookmarks/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(OCA\PreviewGenerator\Command\Generate), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
22 /var/www/html/custom_apps/bookmarks/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
23 /var/www/html/lib/private/Console/Application.php(209): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
24 /var/www/html/console.php(99): OC\Console\Application->run()
25 /var/www/html/occ(11): require_once('/var/www/html/c...')