Skip to content

Conversation

@st3iny
Copy link
Member

@st3iny st3iny commented Nov 11, 2022

Fix nextcloud/previewgenerator#323

Imaginary upstream has introduced the possibility to send width and height of the outputted image along with the request. However, the decision was made that this feature is optional and gated behind a cli parameter (-return-size).

Ref h2non/imaginary#382
Ref https://github.com/h2non/imaginary/pull/382/files#diff-77ed712c0c6f7b52686415504853bc522f5f0ee3e9e0399cfd60a48813aa6aaeR110

Problem

Our code relies on the presence of those headers. If they aren't present, the max values are used as default and thus previews might be distorted. Especially smaller images are affected.

Reproducability

Use both images from the linked issue and generate previews. You'll see that they are always distorted.

With my patch applied they are correct. It doesn't matter if the flag of Imaginary is enabled or not. The performance is slightly better if the flag is enabled.

Documentation

I plan to add a hint to the server tuning docs. We should recommend using the flag by default to admins.

Ref https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html#previews

Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
@st3iny st3iny added bug 3. to review Waiting for reviews feature: previews and thumbnails integration pending documentation This pull request needs an associated documentation update labels Nov 11, 2022
@st3iny st3iny added this to the Nextcloud 26 milestone Nov 11, 2022
@st3iny st3iny requested review from a team, PVince81 and szaimen November 11, 2022 13:35
@st3iny st3iny self-assigned this Nov 11, 2022
Comment on lines -129 to -131
if ($response->getHeader('X-Image-Width') && $response->getHeader('X-Image-Height')) {
$maxX = (int)$response->getHeader('X-Image-Width');
$maxY = (int)$response->getHeader('X-Image-Height');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets wait for @CarlSchwan to chwck if it is okay to not check for this header anymore. It might be possibke that we brake some instances otherwise

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break one instance using my fork of imaginary. I'll communicate this to them after my vacation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative we need to convince the imaginary maintainer that using a X- prefix for custom headers is more correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so. Thanks Carl! :)

Copy link
Contributor

@szaimen szaimen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but didn't test

@st3iny st3iny added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Nov 11, 2022
@szaimen szaimen merged commit 1560c93 into master Nov 11, 2022
@szaimen szaimen deleted the fix/noid/imaginary-distorted-previews branch November 11, 2022 15:56
@szaimen
Copy link
Contributor

szaimen commented Nov 11, 2022

/backport to stable25

@szaimen
Copy link
Contributor

szaimen commented Nov 11, 2022

/backport to stable24

@backportbot-nextcloud
Copy link

The backport to stable25 failed. Please do this backport manually.

@backportbot-nextcloud
Copy link

The backport to stable24 failed. Please do this backport manually.

@szaimen
Copy link
Contributor

szaimen commented Nov 11, 2022

/backport to stable24

@szaimen
Copy link
Contributor

szaimen commented Nov 11, 2022

/backport to stable25

@backportbot-nextcloud
Copy link

The backport to stable24 failed. Please do this backport manually.

@backportbot-nextcloud
Copy link

The backport to stable25 failed. Please do this backport manually.

@szaimen
Copy link
Contributor

szaimen commented Nov 11, 2022

/backport to stable25

@szaimen
Copy link
Contributor

szaimen commented Nov 11, 2022

/backport to stable24

@backportbot-nextcloud
Copy link

The backport to stable25 failed. Please do this backport manually.

@szaimen
Copy link
Contributor

szaimen commented Nov 11, 2022

/backport to stable25

st3iny added a commit to nextcloud/documentation that referenced this pull request Nov 15, 2022
Ref nextcloud/previewgenerator#323
Ref nextcloud/server#35105

Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
@st3iny st3iny removed the pending documentation This pull request needs an associated documentation update label Nov 15, 2022
st3iny added a commit to nextcloud/documentation that referenced this pull request Nov 15, 2022
Ref nextcloud/previewgenerator#323
Ref nextcloud/server#35105

Co-authored-by: Simon L. <szaimen@e.mail.de>
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
backportbot-nextcloud bot pushed a commit to nextcloud/documentation that referenced this pull request Nov 30, 2022
Ref nextcloud/previewgenerator#323
Ref nextcloud/server#35105

Co-authored-by: Simon L. <szaimen@e.mail.de>
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
backportbot-nextcloud bot pushed a commit to nextcloud/documentation that referenced this pull request Nov 30, 2022
Ref nextcloud/previewgenerator#323
Ref nextcloud/server#35105

Co-authored-by: Simon L. <szaimen@e.mail.de>
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to release Ready to be released and/or waiting for tests to finish bug feature: previews and thumbnails integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some images generated with imaginary are incorrect

4 participants