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

avatar generation - disable setimageformat #35891

Merged
merged 1 commit into from
Dec 27, 2022

Conversation

szaimen
Copy link
Contributor

@szaimen szaimen commented Dec 27, 2022

Fix #34755

See #34755 (comment) and #34755 (comment) for context

Signed-off-by: Simon L <szaimen@e.mail.de>
@szaimen szaimen added bug 2. developing Work in progress labels Dec 27, 2022
@szaimen szaimen added this to the Nextcloud 26 milestone Dec 27, 2022
@szaimen
Copy link
Contributor Author

szaimen commented Dec 27, 2022

/backport to stable25

@szaimen szaimen marked this pull request as ready for review December 27, 2022 13:20
@szaimen szaimen added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Dec 27, 2022
@szaimen szaimen requested a review from a team December 27, 2022 13:21
@szaimen szaimen merged commit b90ccaa into master Dec 27, 2022
@szaimen szaimen deleted the fix/34755/disable-setimageformat branch December 27, 2022 15:11
@juliusknorr
Copy link
Member

This actually causes segfaults on cypress tests when creating a new user in text. nextcloud/text#3610 (comment)

@szaimen Do you have any further technical insights on why the png conversion failed? The segfault is also weird, but more elaboration on this fix would be good. Is the Imagick format now kept as svg? In that case OC_Image further down

$image->loadFromData((string)$avatar);
would receive an svg which GD cannot handle. So maybe this just hides the issue and uses the fallback from
$data = $this->generateAvatar($this->getDisplayName(), 1024, $darkTheme);
?

@juliusknorr
Copy link
Member

I actually also have the segfault on my dev instance. It happens when trying to get the image data from imagick using (string)$avatar without setting a format. Would vote to revert this and rather try to check for the reason why the generation fails originally.

@juliusknorr
Copy link
Member

@szaimen Since you could reproduce the original issue can you maybe try if the following patch works instead of this one?

diff --git a/lib/private/Avatar/Avatar.php b/lib/private/Avatar/Avatar.php
index 791cb8b2e7f..fcec7f2dd27 100644
--- a/lib/private/Avatar/Avatar.php
+++ b/lib/private/Avatar/Avatar.php
@@ -126,7 +126,7 @@ abstract class Avatar implements IAvatar {
         * Generate png avatar from svg with Imagick
         */
        protected function generateAvatarFromSvg(int $size, bool $darkTheme): ?string {
-               if (!extension_loaded('imagick')) {
+               if (!extension_loaded('imagick') || count(\Imagick::queryFormats('SVG')) === 0) {
                        return null;
                }
                try {

@szaimen
Copy link
Contributor Author

szaimen commented Dec 29, 2022

Since you could reproduce the original issue can you maybe try if the following patch works instead of this one?

diff --git a/lib/private/Avatar/Avatar.php b/lib/private/Avatar/Avatar.php
index 791cb8b2e7f..fcec7f2dd27 100644
--- a/lib/private/Avatar/Avatar.php
+++ b/lib/private/Avatar/Avatar.php
@@ -126,7 +126,7 @@ abstract class Avatar implements IAvatar {
         * Generate png avatar from svg with Imagick
         */
        protected function generateAvatarFromSvg(int $size, bool $darkTheme): ?string {
-               if (!extension_loaded('imagick')) {
+               if (!extension_loaded('imagick') || count(\Imagick::queryFormats('SVG')) === 0) {
                        return null;
                }
                try {

I tried it but it doesnt work. This is the generated avatar picture:
image

So maybe it is indeed a font problem? However I don't understand why...

@szaimen
Copy link
Contributor Author

szaimen commented Dec 29, 2022

I think I might have found the issue.

@szaimen
Copy link
Contributor Author

szaimen commented Dec 29, 2022

It might be indeed an AIO issue: nextcloud/all-in-one#1624

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
4 participants