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 WebP support #38032

Merged
merged 1 commit into from Sep 2, 2023
Merged

Imaginary WebP support #38032

merged 1 commit into from Sep 2, 2023

Conversation

JanisPlayer
Copy link
Contributor

@JanisPlayer JanisPlayer commented May 3, 2023

Summary

Hello, is my first pull, it was suggested to me in a comment and I must admit I don't really know how to do something like this.
Anyway, this code adds Imaginary WebP support and allows to add an API key.

In theory you could also extend this with e.g. Imaginary_query in the config, where you could just add something like that in the config itself.

However, until now I only wanted to add these two options.

  'preview_format' => 'webp',
  occ config:app:set preview webp_quality --value="30"

If preview_format or webp_quality doesn't exist the default will be used again.

So far WebP works exclusively for Imaginary, if it should work for the other generations I might need some help to find my way around the code.

As a small warning, I am not a skilled application developer only a hobby developer, because it has bothered that WebP does not work.

But I wanted to contribute something to the project and make it work faster.

Hope I did this right.

TODO

  • for image/png application/illustrator you could use lossless or close to lossless WebP, because i don't know now how to do that lossless with imaginary. image/heic you could actually add in WebP support.

Checklist

  • Code is properly formatted
  • Tested
    On web server, android

@solracsf solracsf changed the title This code adds Imaginary WebP support and allows to add an API key in the config. Imaginary WebP support and allows to add an API key in the config May 3, 2023
@szaimen szaimen added the 3. to review Waiting for reviews label May 3, 2023
@szaimen szaimen added this to the Nextcloud 27 milestone May 3, 2023
@szaimen szaimen requested review from st3iny, artonge, come-nc, a team, ArtificialOwl and Fenn-CS and removed request for a team May 3, 2023 12:15
lib/private/Preview/Imaginary.php Outdated Show resolved Hide resolved
@artonge artonge added the pending documentation This pull request needs an associated documentation update label May 3, 2023
@artonge
Copy link
Contributor

artonge commented May 3, 2023

This looks good IMO.
Some documentation will be needed, can you take care of that @JanisPlayer ?

JanisPlayer

This comment was marked as outdated.

@JanisPlayer

This comment was marked as outdated.

@artonge
Copy link
Contributor

artonge commented May 4, 2023

@JanisPlayer there are some lint errors. Can you run composer run cs:fix and push the changes? It should be enough.

$mimeType = 'jpeg';
break;
case 'webp':
$mimeType = 'webp';
Copy link
Contributor

Choose a reason for hiding this comment

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

what I wonder about is if webp previews would need to be explicitely enabled in the client apps. cc @tobiasKaminsky on this

Copy link
Member

Choose a reason for hiding this comment

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

Clients ask via thumbnail api for any image type, as long as mimetype is "image/" or "video/".

Copy link
Contributor

Choose a reason for hiding this comment

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

so the filetype is set by the server? sounds nice!

Copy link
Member

Choose a reason for hiding this comment

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

In general yes. I do not know nothing about this imaginary.
But in e.g. NC26 I can upload any image format and ask for a thumbnail.
Either server can handle it, then I receive a thumbnail or it cannot, then clients show placeholder.

API is: /index.php/apps/files/api/v1/thumbnail/128/128/test/image.tiff

This also works for office files, etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

What I was wondering about was if it is a problem if at this endpoint a webp is returner?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure if it is somewhere stated, or just done all the time, but thumbnails are all pngs.
This should be kept this way.

So for thumbnails, above endpoint, all must convert to png.

config/config.sample.php Outdated Show resolved Hide resolved
@skjnldsv skjnldsv modified the milestones: Nextcloud 27, Nextcloud 28 May 4, 2023
JanisPlayer added a commit to JanisPlayer/documentation that referenced this pull request May 10, 2023
Since it is a getAppValue and not a getSystemValue, the setting cannot be changed like this.
But since it is not yet clear for the rest of the settings which setting in the config is changeable and which is not, there may be another change.
nextcloud/server#38032 (comment)

Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com>
JanisPlayer added a commit to JanisPlayer/server that referenced this pull request May 11, 2023
nextcloud#38032 (comment)

Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com>
@artonge artonge requested a review from szaimen May 15, 2023 09:48
@szaimen
Copy link
Contributor

szaimen commented May 19, 2023

Hi @JanisPlayer can you please create a separate PR for the imaginary_key feature and remove it from this PR? This allows for an easier review and mergeability. Thanks a lot in advance! :)

@miaulalala
Copy link
Contributor

@JanisPlayer if you want some help rebasing your PR, join us here https://cloud.nextcloud.com/call/xs25tz5y and we can chat / have a call

@JanisPlayer

This comment was marked as outdated.

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
@skjnldsv
Copy link
Member

skjnldsv commented Sep 2, 2023

Rebased for you here is how I did it

  1. git reset --hard 92477bc018785eea473cf0e471437add09e3bc3e, to reset to the last commit before the last three merge you had
  2. git rebase -i --autosquash HEAD~14 and then edit all but the first to add f instead of pick and squash all commits into one
  3. git fetch origin master:master
  4. git rebase master
  5. Then force push

@skjnldsv skjnldsv added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Sep 2, 2023
@skjnldsv skjnldsv merged commit 382d791 into nextcloud:master Sep 2, 2023
37 of 38 checks passed
szaimen pushed a commit to JanisPlayer/documentation that referenced this pull request Sep 2, 2023
Since it is a getAppValue and not a getSystemValue, the setting cannot be changed like this.
But since it is not yet clear for the rest of the settings which setting in the config is changeable and which is not, there may be another change.
nextcloud/server#38032 (comment)

Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com>
@invario
Copy link

invario commented Mar 14, 2024

Wondering if anyone has experienced what I detailed in #43878 ?

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 feature: previews and thumbnails pending documentation This pull request needs an associated documentation update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants