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

Switch all images to be loaded via base64 #70

Merged
merged 3 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode
venv
10 changes: 9 additions & 1 deletion create-themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from pathlib import Path

import base64
import jinja2
import yaml
from PIL import Image
Expand All @@ -24,6 +25,12 @@ def average_color(fname):
return "rgba({}, {}, {}, 0.4)".format(*rgb_color)


def base64_encode_file(fname):
with open(fname, 'rb') as image_file:
extension = fname.suffix.split('.')[-1]
base64_utf8_str = base64.b64encode(image_file.read()).decode('utf-8')
return f'data:image/{extension};base64,{base64_utf8_str}'

BACKGROUND_COLORS = {
# Suggested by @okets in issue #42
"blue-red": "rgba(30, 2, 61, 0.4)",
Expand Down Expand Up @@ -68,7 +75,8 @@ def average_color(fname):
folder=folder,
which=which,
app_header_background_color=app_header_background_color,
background_jpg=str(background.name),
background_jpg=base64_encode_file(background),
# background_jpg=str(background.name),
color=color,
suffix=suffix,
)
Expand Down
56 changes: 28 additions & 28 deletions manual-install/ios-themes.yaml

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
pre-commit
yamllint
Jinja2==3.1.4
pillow==10.3.0
pre-commit==3.7.1
PyYAML==6.0.1
yamllint==1.35.1
2 changes: 1 addition & 1 deletion template.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
ios-{{ which }}-mode-{{ color }}{{ suffix }}:
# Global
background-image: "center / cover no-repeat fixed url('/{{ folder }}/themes/ios-themes/{{ background_jpg }}')"
background-image: "center / cover no-repeat fixed url('{{ background_jpg }}')"
lovelace-background: var(--background-image)
primary-color: {{ primary_color }} # from Apple systemOrange {{ which }} mode
light-primary-color: {{ light_primary_color }} # (icons on left menu) (light: systemGray5 from iOS dark mode, dark: XXX)
Expand Down
56 changes: 28 additions & 28 deletions themes/ios-themes.yaml

Large diffs are not rendered by default.