Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: OC_Image::getOrientation(): Return value must be of type int, array returned #452

Open
frnmst opened this issue Feb 27, 2024 · 2 comments
Labels
bug dependencies PRs that update dependencies needs info

Comments

@frnmst
Copy link

frnmst commented Feb 27, 2024

Hello,

I'm running Nextcloud 26.0.11 and previewgenerator 5.4.0.

I am in the process of regenerating the image previews. Unfortunately I get this error:

TypeError: OC_Image::getOrientation(): Return value must be of type int, array returned in /var/www/html/lib/private/legacy/OC_Image.php:460
Stack trace:
#0 /var/www/html/lib/private/legacy/OC_Image.php(494): OC_Image->getOrientation()
#1 /var/www/html/lib/private/Preview/Image.php(52): OC_Image->fixOrientation()
#2 /var/www/html/lib/private/Preview/GeneratorHelper.php(64): OC\Preview\Image->getThumbnail(Object(OC\Files\Node\File), 800, 800)
#3 /var/www/html/lib/private/Preview/Generator.php(440): OC\Preview\GeneratorHelper->getThumbnail(Object(OC\Preview\JPEG), Object(OC\Files\Node\File), 800, 800)
#4 /var/www/html/lib/private/Preview/Generator.php(164): OC\Preview\Generator->getMaxPreview(Object(OC\Files\SimpleFS\SimpleFolder), Object(OC\Files\Node\File), 'image/jpeg', '')
#5 /var/www/html/lib/private/PreviewManager.php(212): OC\Preview\Generator->generatePreviews(Object(OC\Files\Node\File), Array, 'image/jpeg')
#6 /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php(230): OC\PreviewManager->generatePreviews(Object(OC\Files\Node\File), Array)
#7 /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php(212): OCA\PreviewGenerator\Command\Generate->parseFile(Object(OC\Files\Node\File))
#8 /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php(181): OCA\PreviewGenerator\Command\Generate->parseFolder(Object(OC\Files\Node\Folder), Array)
#9 /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php(129): OCA\PreviewGenerator\Command\Generate->generatePathPreviews(Object(OC\User\User), '/fmasotti/files...')
#10 /var/www/html/3rdparty/symfony/console/Command/Command.php(255): OCA\PreviewGenerator\Command\Generate->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/html/3rdparty/symfony/console/Application.php(1009): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/html/3rdparty/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))
#13 /var/www/html/3rdparty/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/html/lib/private/Console/Application.php(211): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/html/console.php(100): OC\Console\Application->run()
#16 /var/www/html/occ(11): require_once('/var/www/html/c...')

As a temporary solution I modified the source code (/var/www/html/lib/private/legacy/OC_Image.php) like this:

public function getOrientation(): int {

    // rest of the function

    $this->exif = $exif;
+   if (gettype($exif['Orientation']) == 'array') {
+       return -1;
+   }
    return $exif['Orientation'];
}

By returning -1, when an array is detected, the program continues its job. I can't do many experiments since this is a production environment.

@joshtrichards
Copy link
Member

That's really weird.

Per PHP $exif['Orientation'] shouldn't itself be an array ever.

I'd be really interested in what is in $exif['Orientation'] in your case.

Do you happen to have a shareable image that triggers this behavior?

Also, what specific version of PHP and OS distribution?

@joshtrichards joshtrichards added bug needs info dependencies PRs that update dependencies labels Mar 30, 2024
@frnmst
Copy link
Author

frnmst commented Mar 30, 2024

I'm running it again because I can't find the text file dump I made so I don't remember the exact file name. Can the error be triggered again without a full regeneration, like this?

docker-compose exec -T --user www-data app php occ preview:generate-all

I'm running Nextcloud 26.0.13, Docker version, not the AIO. It was 26.0.12 at the time I opened this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug dependencies PRs that update dependencies needs info
Projects
None yet
Development

No branches or pull requests

2 participants