From c6c907aa45b6581aa55ab4d004395945a677c344 Mon Sep 17 00:00:00 2001 From: Marti Martz Date: Tue, 21 Mar 2017 08:11:46 -0600 Subject: [PATCH] Mac: Dynamically create the iconset with all alternates (#2272) --- .gitignore | 1 + mac/create_dmg.sh | 26 +++++++++++++++++- ...icon_256x256.png => qupzilla-dmg-icon.png} | Bin 3 files changed, 26 insertions(+), 1 deletion(-) rename mac/images/{qupzilla-dmg-icon.iconset/icon_256x256.png => qupzilla-dmg-icon.png} (100%) diff --git a/.gitignore b/.gitignore index e0715b1f0..897f1d073 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ license_template Makefile* bin/qupzilla bin/QupZilla.dmg +mac/images/qupzilla-dmg-icon.iconset lib*.so* bin/core qupzilla.sh diff --git a/mac/create_dmg.sh b/mac/create_dmg.sh index 38e0a8f8e..6f5e3d905 100755 --- a/mac/create_dmg.sh +++ b/mac/create_dmg.sh @@ -25,7 +25,30 @@ hdiutil create -size 200m "$TMP/$WORK_TEMPLATE" -type SPARSE -fs HFS+ -volname " cp images/qupzilla-dmg-background.png "$TMP/$VOLUME_TEMPLATE/.background/" echo "Creating volume icon set…" - iconutil -c icns images/qupzilla-dmg-icon.iconset -o "$TMP/$VOLUME_TEMPLATE/.VolumeIcon.icns" + ICON=qupzilla-dmg-icon + ICONEXT=png + ICONSETDIR=images/$ICON.iconset + + mkdir -p "$ICONSETDIR" + + # Convert last with qlmanage since sips does not do SVG + qlmanage -t -s 1024 -o "$ICONSETDIR" "images/$ICON.$ICONEXT" + mv "$ICONSETDIR/$ICON.$ICONEXT.png" "$ICONSETDIR/icon_512x512@2x.png" + + # Convert remaining with sips since qlmanage does not do 16 pixels + sizes=( 512 256 128 64 32 16 ) + for size in ${sizes[@]} + do + sips -Z $size -s format png "$ICONSETDIR/icon_512x512@2x.png" --out "$ICONSETDIR/icon_${size}x${size}.png" + + halfsize=$((size / 2)) + if [[ size -ne 16 ]]; then + ln "$ICONSETDIR/icon_${size}x${size}.png" "$ICONSETDIR/icon_${halfsize}x${halfsize}@2x.png" + fi + done + + # iconutil will only pick what it needs + iconutil -c icns "$ICONSETDIR" -o "$TMP/$VOLUME_TEMPLATE/.VolumeIcon.icns" echo "Creating application reference folder…" mkdir "$TMP/$VOLUME_TEMPLATE/QupZilla.app" @@ -58,4 +81,5 @@ rm "$BUNDLE_PATH/QupZilla.dmg" hdiutil convert "$TMP/$WORK_TEMPLATE" -format UDBZ -o "$BUNDLE_PATH/QupZilla.dmg" echo "Cleaning up" +rm -Rf "$ICONSETDIR" rm "$TMP/$WORK_TEMPLATE" diff --git a/mac/images/qupzilla-dmg-icon.iconset/icon_256x256.png b/mac/images/qupzilla-dmg-icon.png similarity index 100% rename from mac/images/qupzilla-dmg-icon.iconset/icon_256x256.png rename to mac/images/qupzilla-dmg-icon.png