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

Update logos and installer branding #12124

Merged
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
12 changes: 6 additions & 6 deletions .github/workflows/pr_build_kolibri.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
dmg:
name: Build DMG file
needs: whl
uses: learningequality/kolibri-app/.github/workflows/[email protected].0
uses: learningequality/kolibri-app/.github/workflows/[email protected].1
with:
whl-file-name: ${{ needs.whl.outputs.whl-file-name }}
ref: v0.4.0
ref: v0.4.1
deb:
name: Build DEB file
needs: whl
Expand All @@ -48,14 +48,14 @@ jobs:
exe:
name: Build EXE file
needs: whl
uses: learningequality/kolibri-installer-windows/.github/workflows/[email protected].3
uses: learningequality/kolibri-installer-windows/.github/workflows/[email protected].4
with:
whl-file-name: ${{ needs.whl.outputs.whl-file-name }}
ref: v1.6.3
ref: v1.6.4
apk:
name: Build APK file
needs: whl
uses: learningequality/kolibri-installer-android/.github/workflows/[email protected].1
uses: learningequality/kolibri-installer-android/.github/workflows/[email protected].2
with:
tar-file-name: ${{ needs.whl.outputs.tar-file-name }}
ref: v0.1.1
ref: v0.1.2
16 changes: 8 additions & 8 deletions .github/workflows/release_kolibri.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ jobs:
dmg:
name: Build DMG file
needs: whl
uses: learningequality/kolibri-app/.github/workflows/[email protected].0
uses: learningequality/kolibri-app/.github/workflows/[email protected].1
with:
whl-file-name: ${{ needs.whl.outputs.whl-file-name }}
release: true
ref: v0.4.0
ref: v0.4.1
secrets:
KOLIBRI_MAC_APP_IDENTITY: ${{ secrets.KOLIBRI_MAC_APP_IDENTITY }}
KOLIBRI_MAC_APP_CERTIFICATE: ${{ secrets.KOLIBRI_MAC_APP_CERTIFICATE }}
Expand Down Expand Up @@ -69,11 +69,11 @@ jobs:
exe:
name: Build EXE file
needs: whl
uses: learningequality/kolibri-installer-windows/.github/workflows/[email protected].3
uses: learningequality/kolibri-installer-windows/.github/workflows/[email protected].4
with:
whl-file-name: ${{ needs.whl.outputs.whl-file-name }}
release: true
ref: v1.6.3
ref: v1.6.4
secrets:
KOLIBRI_WINDOWS_INSTALLER_CERTIFICATE: ${{ secrets.KOLIBRI_WINDOWS_INSTALLER_CERTIFICATE }}
KOLIBRI_WINDOWS_INSTALLER_CERTIFICATE_PASSWORD: ${{ secrets.KOLIBRI_WINDOWS_INSTALLER_CERTIFICATE_PASSWORD }}
Expand All @@ -99,11 +99,11 @@ jobs:
apk:
name: Build Android APK
needs: whl
uses: learningequality/kolibri-installer-android/.github/workflows/[email protected].1
uses: learningequality/kolibri-installer-android/.github/workflows/[email protected].2
with:
tar-file-name: ${{ needs.whl.outputs.tar-file-name }}
release: true
ref: v0.1.1
ref: v0.1.2
secrets:
KOLIBRI_ANDROID_APP_PRODUCTION_KEYSTORE: ${{ secrets.KOLIBRI_ANDROID_APP_PRODUCTION_KEYSTORE }}
KOLIBRI_ANDROID_APP_PRODUCTION_KEYSTORE_PASSWORD: ${{ secrets.KOLIBRI_ANDROID_APP_PRODUCTION_KEYSTORE_PASSWORD }}
Expand Down Expand Up @@ -196,9 +196,9 @@ jobs:
name: Release Android App
if: ${{ !github.event.release.prerelease }}
needs: [apk, block_release_step]
uses: learningequality/kolibri-installer-android/.github/workflows/[email protected].1
uses: learningequality/kolibri-installer-android/.github/workflows/[email protected].2
with:
version-code: ${{ needs.apk.outputs.version-code }}
ref: v0.1.1
ref: v0.1.2
secrets:
KOLIBRI_ANDROID_PLAY_STORE_API_SERVICE_ACCOUNT_JSON: ${{ secrets.KOLIBRI_ANDROID_PLAY_STORE_API_SERVICE_ACCOUNT_JSON }}
2 changes: 1 addition & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
macos:
name: Python unit tests on Mac OS
needs: pre_job
runs-on: macos-latest
runs-on: macos-13
strategy:
max-parallel: 5
matrix:
Expand Down
82 changes: 82 additions & 0 deletions build_tools/logo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import argparse
import os
import tempfile

import cairosvg
from PIL import Image


# The default input size is based off the current size of the Kolibri logo SVG
def convert_svg_to_image(
svg_file_path, output_file_path, input_size=200, final_size=None
):
ext = os.path.splitext(output_file_path)[1].lower()
temp_png_file = tempfile.NamedTemporaryFile(suffix=ext, delete=False)
# Scale up, but don't scale down, as we don't want to lose quality
cairosvg.svg2png(
url=svg_file_path,
write_to=temp_png_file.name,
scale=final_size / input_size
if final_size and final_size > input_size
else 1.0,
)

with Image.open(temp_png_file.name) as img:
# Convert image to RGBA if not already in that mode
if img.mode != "RGBA":
img = img.convert("RGBA")

# Get the bounding box
bbox = img.getbbox()

# Crop the image to the contents
img_cropped = img.crop(bbox)

# Determine the dimensions for a square based on the cropped image
max_dim = max(img_cropped.size)
square_size = (max_dim, max_dim)

# Create a new square image with a transparent background
square_img = Image.new("RGBA", square_size, (0, 0, 0, 0))

# Calculate top-left corner coordinates to paste the cropped image centered in the square canvas
paste_position = (
(max_dim - img_cropped.width) // 2,
(max_dim - img_cropped.height) // 2,
)
square_img.paste(img_cropped, paste_position)

if final_size:
# If a final size is specified, resize the square image to these dimensions
square_img = square_img.resize((final_size, final_size), Image.LANCZOS)

# Remove the dot from the extension and convert to uppercase
output_format = ext[1:].upper()

if output_format == "JPG":
output_format = "JPEG" # Adjust for JPEG

# Convert RGBA to RGB for JPEG, as JPEG does not support transparency
if output_format == "JPEG":
square_img = square_img.convert("RGB")

# Save the final result
square_img.save(output_file_path, format=output_format)


if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Convert SVG to cropped and optionally resized image file - will infer the type from the extension."
)
parser.add_argument("svg_file", help="Path to the input SVG file.")
parser.add_argument("image_file", help="Path to the output file.")
parser.add_argument(
"--size",
type=int,
help="Optional final size to resize the output image to a square of this size.",
default=None,
)

args = parser.parse_args()

convert_svg_to_image(args.svg_file, args.image_file, final_size=args.size)
Loading
Loading