[PR #933] [MERGED] chore: minify background image #541

Closed
opened 2025-10-08 00:12:34 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/pocket-id/pocket-id/pull/933
Author: @ItalyPaleAle
Created: 9/11/2025
Status: Merged
Merged: 9/14/2025
Merged by: @ItalyPaleAle

Base: mainHead: background-img-webp


📝 Commits (10+)

📊 Changes

11 files changed (+195 additions, -22 deletions)

View changed files

📝 backend/internal/bootstrap/application_images_bootstrap.go (+81 -11)
backend/internal/bootstrap/application_images_bootstrap_test.go (+61 -0)
📝 backend/internal/service/app_config_service.go (+1 -1)
📝 backend/internal/utils/email/email_service_templates.go (+3 -3)
📝 backend/internal/utils/file_util.go (+27 -4)
📝 backend/internal/utils/hash_util.go (+19 -0)
backend/resources/images/background.jpg (+0 -0)
backend/resources/images/background.webp (+0 -0)
📝 frontend/src/lib/components/form/profile-picture-settings.svelte (+1 -1)
📝 frontend/src/routes/settings/admin/application-configuration/application-image.svelte (+1 -1)
📝 frontend/src/routes/settings/admin/oidc-clients/oidc-client-form.svelte (+1 -1)

📄 Description

The current background image is a very large JPEG file that is ove 3MB in size. That is a lot of data, especially for users that are not in the LAN.

This PR converts the background image to a smaller one (1440p) and uses the WebP format (supported by all browsers that support WebAuthn). This reduces the size of the background image to just 292KB. That's a 92% reduction!

Because we did not have code in place to replace existing images only if they were the default, I added some support code that checks if file on disk represent legacy default images and deletes them - but only if they were the default ones (hashes are hardcode in the application)

Tested:

  1. A fresh installation writes the webp file
  2. If there's an existing background.jpg AND it's the default one (not uploaded by users), it's deleted
  3. If there's a user-uploaded background file (no matter the extension), it's unchanged

���� This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/pocket-id/pocket-id/pull/933 **Author:** [@ItalyPaleAle](https://github.com/ItalyPaleAle) **Created:** 9/11/2025 **Status:** ✅ Merged **Merged:** 9/14/2025 **Merged by:** [@ItalyPaleAle](https://github.com/ItalyPaleAle) **Base:** `main` ← **Head:** `background-img-webp` --- ### 📝 Commits (10+) - [`70a8e09`](https://github.com/pocket-id/pocket-id/commit/70a8e091a9c22b9b566396d0d3b5483bf5e2202c) chore: minify background image - [`76f4206`](https://github.com/pocket-id/pocket-id/commit/76f4206c113df49d60bbdc02e6d96fc1e9b0339c) Add missing mime types - [`ebc590b`](https://github.com/pocket-id/pocket-id/commit/ebc590b37c0af7a574c63f1f8479db5f7ff7b61f) Add missing mime types to client - [`c113978`](https://github.com/pocket-id/pocket-id/commit/c113978fbbf857125f408a14dfb3287a92b8c6b9) Make image 1440p - [`9abbec2`](https://github.com/pocket-id/pocket-id/commit/9abbec2303723794445303e2cf6483a851bd9fbc) Add test for data - [`28880b0`](https://github.com/pocket-id/pocket-id/commit/28880b08a4aa1726f37834b994a1647f7bc9ab5c) fix linter - [`d9dbfbf`](https://github.com/pocket-id/pocket-id/commit/d9dbfbf4908f278e3abf81dc9f4c1a08c557ef28) Merge branch 'main' into background-img-webp - [`37c08fb`](https://github.com/pocket-id/pocket-id/commit/37c08fb241bdc64796e1c65741e4c4c627cdbbc0) remove size - [`faf6191`](https://github.com/pocket-id/pocket-id/commit/faf6191854048d97f4b84918389958a7262e5bb0) Merge branch 'main' of https://github.com/pocket-id/pocket-id into background-img-webp - [`d84f4ea`](https://github.com/pocket-id/pocket-id/commit/d84f4eae7d6c419fa74b14d7f54cf65166ea3e2d) remove unnecessary image data type ### 📊 Changes **11 files changed** (+195 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `backend/internal/bootstrap/application_images_bootstrap.go` (+81 -11) ➕ `backend/internal/bootstrap/application_images_bootstrap_test.go` (+61 -0) 📝 `backend/internal/service/app_config_service.go` (+1 -1) 📝 `backend/internal/utils/email/email_service_templates.go` (+3 -3) 📝 `backend/internal/utils/file_util.go` (+27 -4) 📝 `backend/internal/utils/hash_util.go` (+19 -0) ➖ `backend/resources/images/background.jpg` (+0 -0) ➕ `backend/resources/images/background.webp` (+0 -0) 📝 `frontend/src/lib/components/form/profile-picture-settings.svelte` (+1 -1) 📝 `frontend/src/routes/settings/admin/application-configuration/application-image.svelte` (+1 -1) 📝 `frontend/src/routes/settings/admin/oidc-clients/oidc-client-form.svelte` (+1 -1) </details> ### 📄 Description The current background image is a very large JPEG file that is ove 3MB in size. That is a lot of data, especially for users that are not in the LAN. This PR converts the background image to a smaller one (1440p) and uses the WebP format (supported by all browsers that support WebAuthn). This reduces the size of the background image to just 292KB. That's a 92% reduction! Because we did not have code in place to replace existing images only if they were the default, I added some support code that checks if file on disk represent legacy default images and deletes them - but only if they were the default ones (hashes are hardcode in the application) Tested: 1. A fresh installation writes the webp file 2. If there's an existing background.jpg AND it's the default one (not uploaded by users), it's deleted 3. If there's a user-uploaded background file (no matter the extension), it's unchanged --- <sub>���� This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2025-10-08 00:12:34 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pocket-id-pocket-id-1#541