Closed janusn closed 1 year ago
I see, that you are persistent.
I'll try to reproduce it. However, I suspect this being either a bug in the server or the imaginary upstream.
@janusn which Imaginary version are you running?
Can you for a test check if it works with the nextcloud/aio-imaginary:latest
image corrrectly?
@szaimen The version of imaginary is 1.2.4.
Yeah, so to make it work correctly, it is required to build imaginary from master IIRC since no new release was pushed since two years. That is what we are doing with the nextcloud/aio-imaginary:latest
image. Hence my question if you could test with that.
@szaimen Thanks for the pointer. I have replaced the container from the image h2non/imaginary:latest with the image nextcloud/aio-imaginary:latest. Unfortunately, it still produces strange distorted previews.
In fact, you can see the previews of the build-in stock photos generated from aio-imaginary are distorted, such as
but the previews of the following photos are correct:
The version of the aio-imaginary:
$ imaginary --version
dev
Right. Then maybe @CarlSchwan has an idea?
On the other hand, the square preview images generated by web interface of Nextcloud are correctly. They respect the aspect ratios and letterboxed correctly.
I couldn't reproduce it. For me it's the exact other way around.
I only enabled the Imaginary provider to be able to isolate the issue. Both square previews generated by generate-all
are fine. Square previews generated by the web interface are weird and look like your examples.
I'm currently investigating the server code to find a difference between both calls to the Preview API.
EDIT: I repeated the procedure multiple times and now all previews are broken. It seems that only the first previews ever generated are fine. After that, all previews are weird, even when I restart the Imaginary server.
If I remember the discussion with Carl correctly, the maintainer of Imaginary submitted in the last moment a commit that broke something. Not sure if it is the same issue though. Probably it is then this: https://github.com/h2non/imaginary/pull/382/commits/234d1fecb7e0bc49f51f6f2152ba77c1d1388fa6 https://github.com/nextcloud/server/search?q=X-Image-Width
I tested some more and noticed that the previews are only broken if the source image is smaller than the actual preview.
E.g. Supplying an Image with 8000x6000 produces correct results. Supplying an image with 640x480 produces weird results because Nextcloud asks for a preview of 1024x1024.
Bingo!
@szaimen This is correct. I added debugging code to Imaginary which dumps each generated image to a file and they are correct. It seems like our server does not parse the width and height values correctly and thus distorts the image.
This should be fixable by parsing both headers.
This should be fixable by parsing both headers
Indeed but only if the header was specified to be emitted, correct?
So rather fail if one of these headers was not found instead of generating false previews?
Yes, but I came up with a workaround. The image is now parsed when width and height are not specified. This has a minor performance impact but there is no way around it. We need to have the exact width and height values or previews will be distorted.
I'm also planning to amend the documentation with a warning to alert admins to use the -return-size
flag.
Ref https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html#previews
Sounds good! :)
I'll also link to the aio docker image of Imaginary because the default one is outdated and doesn't include the flag ...
Fine by me 👍
However I am thjnking about tweaking the container so that -return-size
is added by default. WDYT?
However I am thjnking about tweaking the container so that
-return-size
is added by default. WDYT?
Great idea!
Let me have a look at this then :)
Should we improve the docs on this? Shall I do or will you do @st3iny ? :)
For the document, please mention the registry "nextcloud/aio-imaginary". Otherwise people like me will still get the wrong image. Thanks a ton!
Yes, will do. Thanks for bringing this up!
@szaimen Thanks. I have forgotten to mention. It is better to give the imaginary a real version number to be returned by the following command as well. It is much easier to report any bug on it.
$ imaginary --version
I see, however since this is built staight from their github source code, I don't know how to apply that change...
Should we improve the docs on this? Shall I do or will you do @st3iny ? :)
I'm on it.
Thanks! :)
Some square preview images generated with command
$ occ preview:generate-all -vvv
are a crop of the original images and the aspect ratio are not preserved. On the other hand, the square preview images generated by web interface of Nextcloud are correctly. They respect the aspect ratios and letterboxed correctly.Environment:
The content of the config.php:
The previewgenerator settings:
A sample of an original image:![200042733-9284683a-bf54-4180-b0e4-63faba51b630](https://user-images.githubusercontent.com/21253783/200947427-4945f8ae-507d-40b1-9771-d7bdfbd67f7f.jpg)
The preview generated for both grid view and detailed view on the Files pane.![200042792-55a96c2c-3ce2-4390-b3f3-6d4aa512268d](https://user-images.githubusercontent.com/21253783/200947467-46eb1b8a-ee93-49ec-a672-23dc670ebe06.jpg)
Another example of an original image:![200041760-34ad1f18-4f18-42bc-8549-486b11ad6d82](https://user-images.githubusercontent.com/21253783/200947494-abffb122-529f-4171-a67d-6f8ac848c65e.jpg)
The preview generated for both grid view and detailed view on the Files pane.![200042005-39e74c9b-b6ce-4833-a9f8-e82b23ada8c3](https://user-images.githubusercontent.com/21253783/200947532-ee75f8f6-6225-42bd-8b31-34f6d4c648ca.jpg)