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

Imaginary url-signature-key missing and webp and avif support #37993

Closed
JanisPlayer opened this issue Apr 29, 2023 · 5 comments
Closed

Imaginary url-signature-key missing and webp and avif support #37993

JanisPlayer opened this issue Apr 29, 2023 · 5 comments
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap enhancement feature: previews and thumbnails

Comments

@JanisPlayer
Copy link
Contributor

https://docs.nextcloud.com/server/24/admin_manual/installation/server_tuning.html

Would it maybe be possible to add a key for the API in the nextcloud?
-url-signature-key secret
Currently I have solved this with iptables.
But it would be nice if it were easier to protect against unauthorized access.

I have another idea too.
Generating WepP images via Imaginary would probably be significantly more performant.
I know that there is still no official WebP support for the PHP ImageMagick.
But I think Imaginary is perfect for this, I can generate very small images with great quality on a second server without it greatly affecting the performance of my Nextcloud.
Additional Avif support would of course be even nicer.
I mean Imaginary is a very underused option and can save a lot of memory and JPG can be replaced especially for thumbnails.
#13552
And yes, I know this topic has been discussed many times, but I think it's different with imaginary.

What I also find a pity about Nextcloud is that there is no button with which I can display the original image without downloading it.
Or maybe a short-term stored version (cache) that can be set, for example with 1080p and 90% quality, is supposed to save memory at the expense of performance.

I don't have much memory and can therefore only create JPG images with 30% quality and a maximum of 1024px.
So if you have more than 17K images, that's a problem as far as storage is concerned.
And with WebP I might even be able to specify a target value and not have to worry so much about the quality.

That might be a few ideas to make Nextcloud even better or more usable, because the way it is today, it can't keep up with Google Photos.
PHP alone is simply unsuitable and requires an external service here and it definitely has the ability to create the images quickly enough if there is enough power and I think with Imaginary and a few adjustments Nextcloud can finally keep up with Google without too much storage space waste.

I also have to say that my cell phone gallery app urgently needs a new version, which smears when scrolling and also when too many pictures have to be compared when uploading.
But uploading has gotten better, but you can't show any warnings, otherwise it just spams and crashes.

@JanisPlayer JanisPlayer added 0. Needs triage Pending check for reproducibility or if it fits our roadmap enhancement labels Apr 29, 2023
@JanisPlayer
Copy link
Contributor Author

https://github.com/nextcloud/server/blob/master/lib/private/Preview/Generator.php
you can change this func or ez replace jpeg with webp:
private function getExtention($mimeType) { switch ($mimeType) { case 'image/png': return 'png'; case 'image/webp': return 'webp'; case 'image/gif': return 'gif'; default: throw new \InvalidArgumentException('Not a valid mimetype: "' . $mimeType . '"'); } }
and in this file replace all
https://github.com/nextcloud/server/blob/master/lib/private/Preview/Imaginary.php
from 'type' => $mimeType to 'type' => 'webp',

And WebP works, although this solution is not clean, it is very easy to implement.
And as I said, I'm still waiting for a real solution, here I just replaced JPEG with WebP, actually you should have added it with a setting.

@szaimen
Copy link
Contributor

szaimen commented May 2, 2023

Feel free to create a PR for discussion

@JanisPlayer
Copy link
Contributor Author

JanisPlayer commented May 5, 2023

I have another question, where can I find the instructions or a template on how to develop Nextcloud apps?

In the ticket, I had an idea about HQ previews and displaying images in their original quality on demand. The HQ previews should be temporarily created with a parameter for the preview generator, and optionally stored in a cache folder. This could be helpful for users with limited storage but sufficient bandwidth or computing power.

This means that when the user clicks on an eye icon in the photo view, a drop-down menu opens up. Here, the user can choose between HQ preview and original image. These functions should be configurable later through the app's configuration. For HQ previews, the user can set the maximum resolution and file size. The option to use an HQ preview cache, which retains the most recently created previews and discards rarely used ones once a certain memory or count threshold is reached, can also be enabled.

For displaying original images, the user can choose whether they should be automatically loaded when the preview reaches a desired size. However, I think it would be easier to let the user set this in their profile with a slider.

As you can see, it is a big idea and probably only interesting for users with limited storage who sometimes need near-lossless or full-quality images. Therefore, my question is whether such an idea is possible as an app?
I think displaying the original image with a button press and setting options should be feasible. However, the part with the previews might be complicated and require a separate generator because some modifications might be necessary on the existing preview generator. The cache should be doable, but it also has its downsides in terms of write access.

I also have further ideas for the photo app, I believe it is another department, but this problem also affects the regular file browser.
For example, a better scrolling function that allows the user to scroll to a specific date.
This function is very useful, especially for a huge photo collection like mine.
Usually, I am faster with the SFTP access than navigating through the gallery or the file browser.
So, this would be useful for the regular file browser as well, if a blank list with the most important information is created first and then filled at the point where the user is looking.
This way, you can work much faster with Nextcloud.
However, this is rather an improvement that is helpful when dealing with a large number of files, where the user does not know the name.
Therefore, it is not very important for the regular file browser, but I think many users with a large number of photos would be thrilled with this in the photo app, and it is also easy to implement, as the possibility to display photos from the last year shows.
With the web file browser, it is of course more complicated and could require many database queries, which would need to be optimized by preparing information or only outputting important information such as the number of files.
These are ideas that, if they work or are more feasible, could also make Nextcloud more usable with a huge collection of files on the web.
However, I am aware that services that offer similar capabilities use other file storage techniques and can rely on massive storage and computing power.
Therefore, one would have to strike a balance here in not overburdening the database and server.
To avoid overburdening the client and server, my idea is to first create a list with the number of files and perhaps the most important information such as the name.
Then, when the user scrolls, he or she requests the contents only when they become visible, as it is already partly implemented now.
But, as I said, it is just an idea, and I have no idea whether it is feasible or important to the community.
I just noticed that it becomes difficult with the Nextcloud web interface when dealing with large numbers of files.

Update:
I just looked at how the system works, and it turns out that something like this is already being done, but the online file browser doesn't display the information that is transmitted as XML.
The file browser in the Android app even does what I want it to do right now.
Is there a way to configure this that I might have overlooked?
But now that I know it's technically possible, I'm really excited to implement it. :)
This is actually one of the things that has always bothered me about Nextcloud, and now I know that it can be greatly improved and made more user-friendly.

Update:
Okay, I now have a rough idea of how the system works.
The data is requested via WebDAV, evaluated in the Files app, and then the app displays a maximum of 20 entries.
So, to achieve a similar result, I would need to remove this limitation by replacing it with the maximum number of entries, which would make scrolling much easier.
It's also cool to know that Nextcloud uses WebDAV, and I simply integrated it as a network drive.
Unfortunately, it's without previews, but I can easily and quickly scroll through my files.
I now also have a rough idea of how previews are displayed when you click on a file.
However, I have no experience with this type of web development and would need to learn how to use these templates correctly.
I find it fascinating to look at the code and see how everything works, and I've seen what else is possible with Nextcloud.
As far as I can tell, the later creation of the list in 20 steps is intentional, but it would be cool to have the ability to change this in the config since it could bring me many advantages with regard to the condition.
Maybe I can figure it out myself, but I admit it's difficult for me to understand everything so quickly, especially since it's new to me.
But now I know that what I want to do is possible.

https://github.com/nextcloud/server/tree/master/apps/files
https://github.com/nextcloud/documentation/blob/master/user_manual/files/access_webdav.rst

@joshtrichards
Copy link
Member

I have another question, where can I find the instructions or a template on how to develop Nextcloud apps?

https://docs.nextcloud.com/server/latest/developer_manual/app_development/index.html

Also you might want to pop onto: https://help.nextcloud.com/c/dev/11

@joshtrichards
Copy link
Member

Fixed in #38032 & #38365
Docs: nextcloud/documentation#10256
AVIF stuff tracked in #30118

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap enhancement feature: previews and thumbnails
Projects
None yet
Development

No branches or pull requests

3 participants