Skip to content

Conversation

@leherkom
Copy link
Contributor

Pull request

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Are your git commits signed with a valid GPG key?

New Feature Submissions:

  1. Did you lint your code locally before submission?
  2. Did you test your feature thoroughly to ensure there are no bugs?
  3. Does your feature introduce breaking changes?

Please describe your changes

PoC for a new, more stable way to filter background images. This method uses Rust to decrease the brightness and add the blur on the background image and write out a filtered copy. The copy can then be used as the image source for the Kanban boards.

Uses additional storage space for saving the copy, but ensures that the backgrounds always look the same on all devices. The filters no longer rely on CSS filters applying correctly.

Overview of the general idea:

kanri_-_bg-filters

Additional context

TODOs

  • Needs proper implementation in the frontend
    • Store original background and copy somewhere (the Kanri data directory?) and pass the paths into Rust
    • Invoke Rust on background and blur changes
    • Properly handle the async invocation (currently hangs until the image is done)

Considerations

  • This is not the most efficient way to apply the filters since it always applies both parameters. Because the background doesn't change that often, it should be fine, but it doesn't play well with applying the filters immediately on a change on the slider. Since a gaussian blur is somewhat computationally expensive and backgrounds can be large images, I would suggest changing the dialog to include an "Apply" button rather than applying changes in real time. I experienced some lag when applying a blur to a 4k image on a Ryzen 7 7800X3D. Maybe even limit the maximum size of uploaded images so users can't crash their PC on accident.
  • Note that I only invoke the backend code on the brightness slider for testing. To test, paste paths to existing image files in this part in CustomBackground.vue:
watch(bgBrightnessDebounced, (newVal, oldVal) => {
  if (newVal != oldVal) {
    emit("setBrightness", `${newVal}%`);
    // FIXME: Filter invocation currently not great
    // FIXME: Needs proper image paths
    invoke("filter_bg", {
      brightness: newVal / 100,
      blur: parseInt(bgBlur.value),
      srcPath: "",
      destPath: "",
    });
  }
});

Then open the dialog and move the brightness slider. The filtered image is not yet displayed as the background of the board, but the result can be checked out in the file explorer.

  • In theory, the brightness is a linear interpolation between the original image at 100 and a black screen at 0. During testing I found that changing the brightness below ~60% turns the image really dark really quickly. This might be because of my monitor or my eyes though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant