-
Notifications
You must be signed in to change notification settings - Fork 750
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12124 from rtibbles/non_svg_logos
Update logos and installer branding
- Loading branch information
Showing
18 changed files
with
543 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 }} | ||
|
@@ -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 }} | ||
|
@@ -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 }} | ||
|
@@ -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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.