#!/usr/bin/env bash # # Generates the Google Play store graphics from the app's own icon vectors. # # ./tools/make-store-assets.sh [output-dir] # default: ./store-assets # # Produces, matching Play's asset specs (support.google.com/.../answer/9866151): # icon-512.png 512 x 512 32-bit PNG *with* alpha (ours is full-bleed, # so every pixel ends up opaque anyway) # feature-graphic-1024x500.png 1024 x 500 24-bit PNG, no alpha # # and the Google Ads *App campaign* image set, one per orientation, in app-campaign/: # landscape-1200x628.png 1200 x 628 1.91:1 horizontal placements # square-1200x1200.png 1200 x 1200 1:1 feed / interstitial # portrait-320x480.png 320 x 480 2:3 vertical placements # # The three ad creatives are not scaled copies of one file: Google Ads matches an asset to the # placement's orientation, so one landscape image leaves the portrait and square slots empty. # They embed store-assets/screenshots/phone/03-results.png, so run make-store-screenshots.sh # first if that file is missing — the check below says so instead of rendering an empty hole. # # Output lands in ./store-assets/ *inside* the repo, never in $HOME: the editable sources are # the SVGs in tools/store-assets/ and these PNGs are the files that get uploaded to the Play # Console, so they belong with the release they were made for. Pass a directory to override. set -euo pipefail here="$(cd "$(dirname "$0")" && pwd)" repo="$(dirname "$here")" out="${1:-$repo/store-assets}" mkdir -p "$out" render() { # local svg="$1" width="$2" height="$3" name="$4" mode="$5" inkscape "$svg" \ --export-type=png --export-width="$width" --export-height="$height" \ --export-filename="$out/$name" >/dev/null 2>&1 if [ "$mode" = keep-alpha ]; then # Play asks for a 32-bit PNG here. The SVG's background rect covers the whole # canvas, so the alpha channel is fully opaque — no accidental transparency. magick "$out/$name" -alpha on PNG32:"$out/$name" else magick "$out/$name" -background '#1B5E20' -alpha remove -alpha off PNG24:"$out/$name" fi printf ' %s ' "$out/$name" identify -format '%wx%h %[channels] %b\n' "$out/$name" } echo "Writing store assets to $out" render "$here/store-assets/icon.svg" 512 512 icon-512.png keep-alpha render "$here/store-assets/feature-graphic.svg" 1024 500 feature-graphic-1024x500.png flatten # --- Google Ads App campaign creatives --------------------------------------------------------- # One file per orientation, and each is composed rather than resized: an asset is matched to a # placement's orientation, so three honest layouts beat twenty near-duplicates. 5 MB is the size the # Google Ads image uploader accepts, so an oversized file is flagged here instead of at upload time. ad_max_bytes=$((5 * 1024 * 1024)) shot="$repo/store-assets/screenshots/phone/03-results.png" if [ ! -f "$shot" ]; then echo "error: $shot is missing — all three App campaign creatives embed it." >&2 echo " ./tools/make-store-screenshots.sh # builds it from store-assets/raw-screenshots/phone/" >&2 exit 2 fi ad_out="$out/app-campaign" mkdir -p "$ad_out" render_ad() { # local svg="$1" width="$2" height="$3" name="$4" # Check the *declared* canvas, not the finished file. --export-width/height forces the output # size, so measuring the PNG and comparing it with those two numbers would pass every time — # including for a source edited to a different canvas, which the export flags would then stretch # into the size the Console asked for. This is the check that catches that. local root declared_width declared_height root="$(tr -d '\n' < "$svg" | grep -o ']*>' | head -1)" declared_width="$(printf '%s' "$root" | grep -oE 'width="[0-9]+"' | head -1 | tr -dc '0-9')" declared_height="$(printf '%s' "$root" | grep -oE 'height="[0-9]+"' | head -1 | tr -dc '0-9')" if [ "$declared_width" != "$width" ] || [ "$declared_height" != "$height" ]; then echo "error: $svg declares ${declared_width}x${declared_height} but is rendered at ${width}x${height}" >&2 echo " that would stretch the composition — fix the SVG or the size in this script" >&2 exit 1 fi # --export-area-page is explicit rather than implied, because these three bleed: the screenshot # card is cut by the canvas edge, so the drawing bbox is taller than the page (1200x710 for the # landscape one). Inkscape 1.x already exports the page here — checked pixel-identical with and # without the flag, 0 differing pixels — but 0.92 defaulted to the drawing bbox, which would # rescale this whole composition into 1200x628 and squash it. inkscape "$svg" \ --export-type=png --export-area-page \ --export-width="$width" --export-height="$height" \ --export-filename="$ad_out/$name" >/dev/null 2>&1 # Flatten against the brand colour: an ad is shown on the placement's own background, so an # alpha channel is how a stray transparent pixel ends up in something a customer sees. # -strip follows from the timestamp problem: Inkscape stamps every fresh render with tIME, so # without it a re-run of this script is pixel-identical but byte-different, and every build # would leave three "modified" files in git. Stripping is metadata-only — measured 0 differing # pixels with and without it. magick "$ad_out/$name" -background '#1B5E20' -alpha remove -alpha off -strip \ PNG24:"$ad_out/$name" # And the finished file, because an Inkscape old enough to ignore --export-width would write the # page size here instead — which the declared-canvas check above cannot see. local got_width got_height got_width="$(identify -format '%w' "$ad_out/$name")" got_height="$(identify -format '%h' "$ad_out/$name")" if [ "$got_width" != "$width" ] || [ "$got_height" != "$height" ]; then echo "error: $name came out ${got_width}x${got_height}, expected ${width}x${height}" >&2 echo " check the width/height and viewBox in $svg" >&2 exit 1 fi local warn='' if [ "$(identify -format '%B' "$ad_out/$name")" -gt "$ad_max_bytes" ]; then warn=' ⚠️ over the 5 MB image limit — re-encode before uploading' fi printf ' %s ' "$ad_out/$name" identify -format '%wx%h %[channels] %b' "$ad_out/$name" printf '%s\n' "$warn" } echo "App campaign images (Google Ads), shot embedded: $shot" render_ad "$here/store-assets/app-campaign-landscape.svg" 1200 628 landscape-1200x628.png render_ad "$here/store-assets/app-campaign-square.svg" 1200 1200 square-1200x1200.png render_ad "$here/store-assets/app-campaign-portrait.svg" 320 480 portrait-320x480.png echo "Done. Play: icon-512.png + feature-graphic-1024x500.png" echo " Ads: app-campaign/landscape-1200x628.png, square-1200x1200.png, portrait-320x480.png" echo " ^ upload these PNGs; the tools/store-assets/*.svg are sources, and Ads rejects SVG" echo " Screenshots: ./tools/make-store-screenshots.sh # reads store-assets/raw-screenshots/phone/" echo " Tablets: FORM_FACTOR=tablet-7in ./tools/make-store-screenshots.sh" echo " FORM_FACTOR=tablet-10in ./tools/make-store-screenshots.sh"