Skip to content

Commit 520b5e0

Browse files
committed
generate a custom background image for the dmg installer with drag instructions
1 parent 4690fec commit 520b5e0

2 files changed

Lines changed: 71 additions & 3 deletions

File tree

.github/actions/create-dmg/action.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ runs:
2121
run: |
2222
brew install create-dmg
2323
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.x'
28+
29+
- name: Install dependencies
30+
shell: bash
31+
run: pip install Pillow
32+
2433
- name: Stage app for DMG
2534
shell: bash
2635
run: |
@@ -30,7 +39,12 @@ runs:
3039
cp -R "${{ inputs.app_path }}" "dmg-stage/CopyShot.app"
3140
ln -s /Applications "dmg-stage/Applications"
3241
33-
- name: Create drag-to-Applications DMG
42+
- name: Generate background image
43+
shell: bash
44+
run: |
45+
python3 .github/actions/create-dmg/scripts/generate_background.py "dmg-stage/background.png"
46+
47+
- name: Create polished drag-to-Applications DMG
3448
shell: bash
3549
run: |
3650
set -euo pipefail
@@ -41,8 +55,9 @@ runs:
4155
# Window and icon sizes/positions are in pixels.
4256
create-dmg \
4357
--volname "${{ inputs.volname }}" \
44-
--window-pos 200 120 \
45-
--window-size 700 450 \
58+
--background "dmg-stage/background.png" \
59+
--window-pos 400 300 \
60+
--window-size 700 500 \
4661
--icon-size 140 \
4762
--icon "CopyShot.app" 180 225 \
4863
--icon "Applications" 520 225 \
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env python3
2+
import sys
3+
from PIL import Image, ImageDraw, ImageFont
4+
5+
def create_background(output_path):
6+
width, height = 700, 500
7+
background_color = (240, 240, 240) # Light gray
8+
arrow_color = (100, 100, 100) # Dark gray
9+
text_color = (80, 80, 80) # Darker gray
10+
11+
# Create image
12+
img = Image.new('RGB', (width, height), color=background_color)
13+
draw = ImageDraw.Draw(img)
14+
15+
# Coordinates
16+
icon_y = 225 + 70 # Center of icon (roughly)
17+
start_x = 180 + 70 + 20 # Right edge of app icon
18+
end_x = 520 - 20 # Left edge of Applications icon
19+
20+
# Draw arrow
21+
# Line
22+
draw.line([(start_x, icon_y), (end_x, icon_y)], fill=arrow_color, width=4)
23+
# Arrowhead
24+
arrow_head = [(end_x, icon_y), (end_x - 15, icon_y - 10), (end_x - 15, icon_y + 10)]
25+
draw.polygon(arrow_head, fill=arrow_color)
26+
27+
# Add text
28+
text = "Drag CopyShot to Applications"
29+
try:
30+
# Try to use a system font
31+
font = ImageFont.truetype("/System/Library/Fonts/Helvetica.ttc", 24)
32+
except IOError:
33+
# Fallback to default if system font not found (e.g. on Linux runner)
34+
font = ImageFont.load_default()
35+
36+
# Calculate text position (centered above arrow)
37+
text_bbox = draw.textbbox((0, 0), text, font=font)
38+
text_width = text_bbox[2] - text_bbox[0]
39+
text_x = start_x + (end_x - start_x - text_width) // 2
40+
text_y = icon_y - 40
41+
42+
draw.text((text_x, text_y), text, fill=text_color, font=font)
43+
44+
# Save
45+
img.save(output_path)
46+
print(f"Background saved to {output_path}")
47+
48+
if __name__ == "__main__":
49+
if len(sys.argv) < 2:
50+
print("Usage: generate_background.py <output_path>")
51+
sys.exit(1)
52+
53+
create_background(sys.argv[1])

0 commit comments

Comments
 (0)