Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
add a background image to the macos dmg install window (#7827)
Maheswar Kumarc8e657e71741
diff --git a/scripts/make_dmg_background.py b/scripts/make_dmg_background.pynew file mode 100644index 00000000000..361d7bea2d5--- /dev/null+++ b/scripts/make_dmg_background.py@@ -0,0 +1,201 @@+#!/usr/bin/env python3+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""Render the macOS DMG install-window background.++Writes studio/src-tauri/dmg/background.tiff, the image Finder draws behind the+app icon and the Applications alias when the disk image opens.++The layout is tied to the Finder coordinates in studio/src-tauri/tauri.macos.conf.json.+Finder maps icon positions onto the background from the same origin, so the base+page has to match dmg.windowSize exactly or the artwork slides out from under the+icons. tests/studio/test_tauri_branding_contract.py holds that contract.++Output is a two-page TIFF: a base page at window size and a second page at twice+that, which is how Finder picks up a sharp image on a retina display.+"""++from __future__ import annotations++import subprocess+import tempfile+from pathlib import Path++import numpy as np+from PIL import Image, ImageDraw+++REPO = Path(__file__).resolve().parents[1]+OUTPUT = REPO / "studio/src-tauri/dmg/background.tiff"++# window geometry in points, mirroring tauri.macos.conf.json+WIN_W, WIN_H = 660, 400+APP_X, APP_Y = 180, 170+APPS_X, APPS_Y = 480, 170++# the base page renders at 1pt per pixel, the hidpi page at SCALE+SCALE = 2+W, H = WIN_W * SCALE, WIN_H * SCALE++# Finder's title bar and bottom path bar eat the rest of the window, so only+# about this much of the image is ever on screen. measured, not derived.+VISIBLE_H = 340++# base surface: near-white with a barely-there cool gradient toward the bottom+TOP_COLOR = "#FFFFFF"+BOTTOM_COLOR = "#F5F8F7"++# One brand green fading to a lighter green further out. Mixing several hues+# around the icon made some directions read stronger than others even at matched+# alpha, so the halo varies by radius only and is even by construction.+GLOW_CORE = "#17B88B"+GLOW_EDGE = "#7BE8A6"+GLOW_EDGE_MIX = 0.45+GLOW_MIX_RADIUS = 130.0++# strength is the peak tint, sigma sets how far the halo reaches. they trade+# off: raising strength alone also pushes the visible edge outward.+GLOW_STRENGTH = 1.85+GLOW_SIGMA = 47.0++# the icon label sits just below the icon, so the halo is eased off downward.+# left, right and top keep the full falloff.+GLOW_BOTTOM_FLOOR = 0.55+GLOW_BOTTOM_SPAN = 90.0++# chevron between the two icons, sized to match the macOS installers this+# mirrors: a light 16x27pt mark in neutral grey, not a heavy arrow+CHEVRON_HALF_W, CHEVRON_HALF_H = 8.0, 13.5+CHEVRON_STROKE = 6.0+CHEVRON_COLOR = (87, 87, 87, 255)++# ImageDraw has no anti-aliasing, so the chevron is drawn oversized and scaled+# back down. its diagonals alias badly otherwise.+CHEVRON_SUPERSAMPLE = 4+++def hex_rgb(value: str) -> np.ndarray:+ value = value.lstrip("#")+ return np.array([int(value[i : i + 2], 16) / 255.0 for i in (0, 2, 4)], dtype = np.float32)+++def smoothstep(edge: np.ndarray) -> np.ndarray:+ clamped = np.clip(edge, 0.0, 1.0)+ return clamped * clamped * (3.0 - 2.0 * clamped)+++def base_canvas() -> np.ndarray:+ ramp = np.linspace(0.0, 1.0, H, dtype = np.float32)[:, None, None]+ return hex_rgb(TOP_COLOR) * (1.0 - ramp) + hex_rgb(BOTTOM_COLOR) * ramp+++def render_glow(canvas: np.ndarray) -> np.ndarray:+ ys, xs = np.mgrid[0:H, 0:W].astype(np.float32)+ cx, cy = APP_X * SCALE, APP_Y * SCALE+ sigma = GLOW_SIGMA * SCALE++ radius = np.sqrt((xs - cx) ** 2 + (ys - cy) ** 2)+ weight = GLOW_STRENGTH * np.exp(-(radius**2) / (2.0 * sigma**2))++ # smoothstep so the taper starts flat at the icon's centre line and leaves+ # no visible seam where it begins+ weight = weight * (+ 1.0 - (1.0 - GLOW_BOTTOM_FLOOR) * smoothstep((ys - cy) / (GLOW_BOTTOM_SPAN * SCALE))+ )++ # a peak strength above 1 saturates the core rather than extrapolating past+ # the glow colour. that core sits under the app icon either way.+ weight = np.clip(weight, 0.0, 1.0)[..., None]++ mix = (GLOW_EDGE_MIX * smoothstep(radius / (GLOW_MIX_RADIUS * SCALE)))[..., None]+ color = hex_rgb(GLOW_CORE) * (1.0 - mix) + hex_rgb(GLOW_EDGE) * mix++ return canvas * (1.0 - weight) + color * weight+++def draw_chevron(image: Image.Image) -> None:+ """Rounded chevron pointing from the app icon toward Applications."""+ ss = CHEVRON_SUPERSAMPLE+ layer = Image.new("RGBA", (image.width * ss, image.height * ss), (0, 0, 0, 0))+ draw = ImageDraw.Draw(layer)++ cx = ((APP_X + APPS_X) / 2) * SCALE * ss+ cy = APP_Y * SCALE * ss+ half_w, half_h = CHEVRON_HALF_W * SCALE * ss, CHEVRON_HALF_H * SCALE * ss+ stroke = CHEVRON_STROKE * SCALE * ss++ points = [(cx - half_w, cy - half_h), (cx + half_w, cy), (cx - half_w, cy + half_h)]+ draw.line(points, fill = CHEVRON_COLOR, width = int(stroke), joint = "curve")+ for x, y in points:+ draw.ellipse(+ [x - stroke / 2, y - stroke / 2, x + stroke / 2, y + stroke / 2],+ fill = CHEVRON_COLOR,+ )++ image.alpha_composite(layer.resize(image.size, Image.LANCZOS))+++def build() -> Image.Image:+ canvas = render_glow(base_canvas())+ pixels = np.clip(canvas * 255.0 + 0.5, 0, 255).astype(np.uint8)+ image = Image.fromarray(pixels).convert("RGBA")+ draw_chevron(image)+ return image+++def report() -> None:+ """Print how the halo sits relative to the icon and its label."""+ base = base_canvas()+ # the halo on its own, with the base gradient taken back out so the vertical+ # ramp does not read as part of it+ halo = np.clip(base - render_glow(base), 0.0, None).max(axis = 2)+ cx, cy = APP_X * SCALE, APP_Y * SCALE++ for name, sample in (+ ("left", halo[cy, cx - 90 * SCALE]),+ ("right", halo[cy, cx + 90 * SCALE]),+ ("up", halo[cy - 90 * SCALE, cx]),+ ("down", halo[cy + 90 * SCALE, cx]),+ ):+ print(f" {name:<5} at 90pt {sample * 100:5.1f}%")++ visible = np.nonzero(halo[cy, :cx] > 0.03)[0]+ print(f" reach {(cx - visible.min()) / SCALE:5.0f}pt")++ label = halo[238 * SCALE : 260 * SCALE, 140 * SCALE : 220 * SCALE]+ print(f" icon label {label.mean() * 100:5.1f}% mean, {label.max() * 100:5.1f}% peak")+++def write_tiff(image: Image.Image, destination: Path) -> None:+ """Combine a base and a hidpi page into the multi-page TIFF Finder expects."""+ with tempfile.TemporaryDirectory() as workspace:+ base_page = Path(workspace) / "base.png"+ hidpi_page = Path(workspace) / "hidpi.png"++ image.resize((WIN_W, WIN_H), Image.LANCZOS).convert("RGB").save(base_page)+ image.convert("RGB").save(hidpi_page)++ destination.parent.mkdir(parents = True, exist_ok = True)+ subprocess.run(+ [+ "tiffutil",+ "-cathidpicheck",+ str(base_page),+ str(hidpi_page),+ "-out",+ str(destination),+ ],+ check = True,+ stdout = subprocess.DEVNULL,+ )+++def main() -> None:+ write_tiff(build(), OUTPUT)+ report()+ print(f"wrote {OUTPUT.relative_to(REPO)}")+++if __name__ == "__main__":+ main()diff --git a/studio/src-tauri/dmg/background.tiff b/studio/src-tauri/dmg/background.tiffnew file mode 100644index 00000000000..ed4dc749da7Binary files /dev/null and b/studio/src-tauri/dmg/background.tiff differdiff --git a/studio/src-tauri/tauri.macos.conf.json b/studio/src-tauri/tauri.macos.conf.jsonindex b1517a62342..dc9fdaadc3b 100644--- a/studio/src-tauri/tauri.macos.conf.json+++ b/studio/src-tauri/tauri.macos.conf.json@@ -4,8 +4,10 @@"entitlements": "./Entitlements.plist","infoPlist": "./Info.plist","dmg": {- "appPosition": { "x": 180, "y": 220 },- "applicationFolderPosition": { "x": 480, "y": 220 }+ "background": "./dmg/background.tiff",+ "windowSize": { "width": 660, "height": 400 },+ "appPosition": { "x": 180, "y": 170 },+ "applicationFolderPosition": { "x": 480, "y": 170 }}}}diff --git a/tests/studio/test_tauri_branding_contract.py b/tests/studio/test_tauri_branding_contract.pyindex a70b7a57e34..9eebb131856 100644--- a/tests/studio/test_tauri_branding_contract.py+++ b/tests/studio/test_tauri_branding_contract.py@@ -25,6 +25,27 @@ def bmp_metadata(path: Path) -> tuple[int, int, int]:return width, height, bits_per_pixel+def tiff_first_image_size(path: Path) -> tuple[int, int]:+ """Width and height of the first image in a TIFF, ignoring later hidpi pages."""+ data = path.read_bytes()+ assert data[:2] in (b"II", b"MM")+ order = "<" if data[:2] == b"II" else ">"++ ifd_offset = struct.unpack_from(order + "I", data, 4)[0]+ entry_count = struct.unpack_from(order + "H", data, ifd_offset)[0]++ sizes: dict[int, int] = {}+ for index in range(entry_count):+ entry = ifd_offset + 2 + index * 12+ tag, field_type = struct.unpack_from(order + "HH", data, entry)+ if tag in (256, 257):+ # tag 256 is ImageWidth and 257 is ImageLength, either SHORT or LONG+ sizes[tag] = struct.unpack_from(+ order + ("H" if field_type == 3 else "I"), data, entry + 8+ )[0]+ return sizes[256], sizes[257]++def test_desktop_display_name_and_compatibility_ids() -> None:config = json.loads(read(TAURI / "tauri.conf.json"))assert config["productName"] == "Unsloth"@@ -81,6 +102,21 @@ def test_desktop_artwork_uses_plain_unsloth_lockups() -> None:assert bmp_metadata(branding / "nsis-sidebar.bmp") == (328, 628, 24)+def test_dmg_install_window_matches_its_background_art() -> None:+ dmg = json.loads(read(TAURI / "tauri.macos.conf.json"))["bundle"]["macOS"]["dmg"]+ assert dmg["background"] == "./dmg/background.tiff"++ # Finder lays the background out from the same origin it uses for icon+ # coordinates, so the base page has to match the configured window size or+ # the artwork drifts out from under the app and Applications icons.+ window = (dmg["windowSize"]["width"], dmg["windowSize"]["height"])+ assert window == (660, 400)+ assert tiff_first_image_size(TAURI / "dmg/background.tiff") == window++ assert dmg["appPosition"] == {"x": 180, "y": 170}+ assert dmg["applicationFolderPosition"] == {"x": 480, "y": 170}++def test_desktop_release_asset_names_are_human_readable() -> None:workflow = read(REPO / ".github/workflows/release-desktop.yml")assert "re.sub(r'[^0-9A-Za-z]+', '_', app_version).strip('_')" in workflow