A professional macOS script that creates beautiful, installer-ready DMG files from your .app bundles with custom backgrounds, arrow graphics, and proper positioning.
- ✨ Custom Background - Gradient background with installation arrow
- 📱 Professional Layout - App positioned on left, Applications link on right
- 🎯 Material Design Arrow - Thick, modern arrow pointing from app to Applications
- 🖼️ Custom Volume Icon - Uses your app's icon for the DMG volume
- 📦 Version Support - Optional versioning in filename
- 🔧 Multiple Fallbacks - Python PIL, ImageMagick, or basic backgrounds
- 🍎 Native macOS Tools - Uses hdiutil, AppleScript, and SetFile
- macOS with developer tools (Xcode Command Line Tools)
- Your .app bundle
- Optional but recommended:
- Python 3 with PIL/Pillow for best arrow quality
- ImageMagick for fallback arrow creation
- Download the script:
curl -O https://github.com/Kristapsp13/DMG-creator-script.git/create_dmg.sh
chmod +x create_dmg.sh- Optional: Install Python PIL for best results:
pip3 install Pillow./create_dmg.sh YourApp.appCreates: YourApp.dmg
./create_dmg.sh YourApp.app v2.0.0Creates: YourApp_mac_v2.0.0.dmg
The script generates a professional DMG with:
- Window Size: 600x400 pixels
- App Position: Left side (150, 200)
- Applications Link: Right side (450, 200)
- Icon Size: 128x128 pixels
- Background: Light gray to white gradient
- Arrow: 12px thick Material Design style arrow
- Arrow Style: Sharp triangle tip with rounded line caps
- Volume Icon: Your app's icon (if available)
- Your .app bundle
- Symbolic link to /Applications folder
- Hidden background image (
.background/background.png) - Custom .DS_Store for layout
- Volume icon (
.VolumeIcon.icns)
# Parse arguments and set up variables
APP_BUNDLE="$1"
VERSION="$2"
DMG_NAME="${APP_NAME}_mac_${VERSION}.dmg" # With version
# or
DMG_NAME="${APP_NAME}.dmg" # Without version# Create temporary 200MB DMG
hdiutil create -size 200m -fs HFS+ -volname "$VOLUME_NAME" "$TEMP_DMG"
# Mount it
hdiutil attach "$TEMP_DMG" -mountpoint "$MOUNT_POINT"# Copy your app
cp -R "$APP_BUNDLE" "$MOUNT_POINT/"
# Create Applications symlink
ln -s /Applications "$MOUNT_POINT/Applications"The script tries multiple methods in order:
# Creates 600x400 gradient background
# Draws 12px thick arrow with rounded caps
# Sharp triangle pointing to Applicationsmagick -size 600x400 gradient:'#f5f5f5-#ffffff' \
-stroke '#646464' -strokewidth 12 \
-draw "line 240,200 352,200" \
-draw "circle 240,200 246,200" \
-draw "polygon 360,200 325,178 325,222"Uses macOS built-in tools to create simple background.
# AppleScript configures the DMG window
set current view of dmg_window to icon view
set icon size of icon_view_options to 128
set position of item "YourApp.app" to {150, 200}
set position of item "Applications" to {450, 200}
set background picture to file ".background:background.png"# Set volume icon
cp "$APP_BUNDLE/Contents/Resources/AppIcon.icns" "$MOUNT_POINT/.VolumeIcon.icns"
# Hide background folder
SetFile -a V "$MOUNT_POINT/.background"
# Unmount and compress
hdiutil detach "$MOUNT_POINT"
hdiutil convert "$TEMP_DMG" -format UDZO -imagekey zlib-level=9 -o "$DMG_NAME"The arrow is designed with Material Design principles:
- Thickness: 12px for bold visibility
- Length: Shortened to not overlap with triangle
- Style: Sharp triangle tip, rounded line caps
- Color: Medium gray (
#646464/rgb(100,100,100))
Current layout positions:
app_x, app_y = 150, 200 # App icon position
apps_x, apps_y = 450, 200 # Applications position
arrow_start_x = app_x + 90 # Arrow starts closer to icon center
arrow_end_x = apps_x - 90 # Arrow ends closer to Applications- Size: 600x400 pixels
- Gradient: Light gray (
#f5f5f5) to white (#ffffff) - Format: PNG with transparency support
Install Python Pillow:
pip3 install Pillow
# or
python3 -m pip install --user PillowInstall ImageMagick:
brew install imagemagickThis is normal - the DMG will still work without custom appearance.
Check that your .app bundle is valid:
# Should show bundle structure
ls -la YourApp.app/Contents/The script tries multiple methods. Check console output:
- ✅ "Python PIL found" = Best quality arrow
- ✅ "ImageMagick background created" = Good quality arrow
⚠️ "Fallback background created" = No arrow, but DMG works
YourApp.dmg (mounted)
├── YourApp.app/
├── Applications -> /Applications
├── .background/
│ └── background.png
├── .DS_Store
└── .VolumeIcon.icns
- Required: macOS, hdiutil, SetFile, osascript
- Optional: Python 3 + PIL, ImageMagick
- Fallback: Built-in macOS image tools
- macOS: 10.12+ (tested on modern versions)
- Python: 3.6+ with PIL/Pillow
- ImageMagick: v6 or v7 (auto-detected)
./create_dmg.sh MyEditor.app v3.1.4
# Creates: MyEditor_mac_v3.1.4.dmg./create_dmg.sh MyApp.app beta-2.0
# Creates: MyApp_mac_beta-2.0.dmg./create_dmg.sh Calculator.app
# Creates: Calculator.dmgThis script is provided as-is for creating macOS application installers. Modify as needed for your distribution requirements.