diff --git a/.gitignore b/.gitignore index d1a7f0e5..cd236617 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ .cxx local.properties /tmp +/bin/__pycache__/ diff --git a/.python-version b/.python-version new file mode 100644 index 00000000..7d4ef04f --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.10.3 diff --git a/bin/generate_fastlane_screenshots.py b/bin/generate_fastlane_screenshots.py new file mode 100755 index 00000000..5a58df9f --- /dev/null +++ b/bin/generate_fastlane_screenshots.py @@ -0,0 +1,93 @@ +#! /usr/bin/env python +# Regenerate the fastlane screenshot files. +# ASSUMES: ImageMagick is installed. + +import subprocess +from typing import Optional, Sequence, Tuple +import os + +TIMEOUT = 60 # seconds + +SRC="Play-assets" +DST="fastlane/metadata/android" + + +def run_cmd2(tokens, trim=True, timeout=TIMEOUT, env=None, input_=None): + # type: (Sequence[str], bool, Optional[int], Optional[dict], Optional[str]) -> Tuple[str, str] + """Run a shell command-line (in token list form) and return a tuple + containing its (stdout, stderr). + This does not expand filename patterns or environment variables or do other + shell processing steps. + + Args: + tokens: The command line as a list of string tokens. + trim: Whether to trim trailing whitespace from the output. This is + useful because the output usually ends with a newline. + timeout: timeout in seconds; None for no timeout. + env: optional environment variables for the new process to use instead + of inheriting the current process' environment. + input_: input for any prompts that may appear (passed to the subprocess' stdin) + Returns: + The command's stdout and stderr strings. + Raises: + OSError (e.g. FileNotFoundError [Python 3] or PermissionError), + subprocess.SubprocessError (TimeoutExpired or CalledProcessError) + """ + out = subprocess.run( + tokens, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + check=True, + env=env, + encoding='utf-8', + timeout=timeout, + input=input_) + if trim: + return out.stdout.rstrip(), out.stderr.rstrip() + return out.stdout, out.stderr + + +def run_cmd(tokens, trim=True, timeout=TIMEOUT, env=None, input_=None): + # type: (Sequence[str], bool, Optional[int], Optional[dict], Optional[str]) -> str + """Run a shell command-line (in token list form), print tokens and any stderr, + then return the stdout. + """ + print(tokens) + + stdout, stderr = run_cmd2(tokens, trim=trim, timeout=timeout, env=env, input_=input_) + + if stderr: + print(f'stderr={stderr}') + return stdout + + +def resize_image_file(src_file: str, dst_file: str, scale: float) -> str: + """This will resize an image file and convert the format per dst_file.""" + input_options = () + # Size and other adjustments to scale and keep the aspect ratio. + # output_options = ('-resize', '100x100^' '-gravity', 'center', '-extent', '100x100') + output_options = ('-resize', f'{scale * 100:.3f}%') + tokens = ['convert', *input_options, src_file, *output_options, dst_file] + return run_cmd(tokens) + + +def resize_batch(phone: bool = True, en: bool = True) -> None: + """Resize a batch of images and convert them to jpeg format.""" + src_model = 'Pixel 3' if phone else 'Pixel C' + dst_model = 'phone' if phone else 'tenInch' + scale = 736/2160 if phone else 1047/2560 + src_locale = '' if en else 'de ' + dst_locale = 'en-US' if en else 'de' + src_dir = f'{SRC}/{src_model} {src_locale}screenshots' + dst_dir = f'{DST}/{dst_locale}/images/{dst_model}Screenshots' + src_files = list(os.listdir(src_dir)) + png_files = list(filter(lambda e: e.endswith('.png'), src_files)) + print(f'SOURCE: {src_dir}; DESTINATION: {dst_dir}') + for i, src_file in enumerate(png_files): + resize_image_file(f'{src_dir}/{src_file}', f'{dst_dir}/{i:02d}.jpg', scale) + +if __name__ == '__main__': + resize_batch(True, True) + resize_batch(False, True) + resize_batch(True, False) + resize_batch(False, False) diff --git a/fastlane/metadata/android/de/images/phoneScreenshots/00.jpg b/fastlane/metadata/android/de/images/phoneScreenshots/00.jpg index e6d96444..5533e97a 100644 Binary files a/fastlane/metadata/android/de/images/phoneScreenshots/00.jpg and b/fastlane/metadata/android/de/images/phoneScreenshots/00.jpg differ diff --git a/fastlane/metadata/android/de/images/phoneScreenshots/01.jpg b/fastlane/metadata/android/de/images/phoneScreenshots/01.jpg index 6772fd1d..5b49af3e 100644 Binary files a/fastlane/metadata/android/de/images/phoneScreenshots/01.jpg and b/fastlane/metadata/android/de/images/phoneScreenshots/01.jpg differ diff --git a/fastlane/metadata/android/de/images/phoneScreenshots/02.jpg b/fastlane/metadata/android/de/images/phoneScreenshots/02.jpg index aa7d7c7f..2c5a7131 100644 Binary files a/fastlane/metadata/android/de/images/phoneScreenshots/02.jpg and b/fastlane/metadata/android/de/images/phoneScreenshots/02.jpg differ diff --git a/fastlane/metadata/android/de/images/phoneScreenshots/03.jpg b/fastlane/metadata/android/de/images/phoneScreenshots/03.jpg index 5533e97a..e5b03ddd 100644 Binary files a/fastlane/metadata/android/de/images/phoneScreenshots/03.jpg and b/fastlane/metadata/android/de/images/phoneScreenshots/03.jpg differ diff --git a/fastlane/metadata/android/de/images/phoneScreenshots/04.jpg b/fastlane/metadata/android/de/images/phoneScreenshots/04.jpg index 5b49af3e..8b3edd39 100644 Binary files a/fastlane/metadata/android/de/images/phoneScreenshots/04.jpg and b/fastlane/metadata/android/de/images/phoneScreenshots/04.jpg differ diff --git a/fastlane/metadata/android/de/images/phoneScreenshots/05.jpg b/fastlane/metadata/android/de/images/phoneScreenshots/05.jpg index c2330c83..3bc10b88 100644 Binary files a/fastlane/metadata/android/de/images/phoneScreenshots/05.jpg and b/fastlane/metadata/android/de/images/phoneScreenshots/05.jpg differ diff --git a/fastlane/metadata/android/de/images/phoneScreenshots/06.jpg b/fastlane/metadata/android/de/images/phoneScreenshots/06.jpg index a15127b1..c2330c83 100644 Binary files a/fastlane/metadata/android/de/images/phoneScreenshots/06.jpg and b/fastlane/metadata/android/de/images/phoneScreenshots/06.jpg differ diff --git a/fastlane/metadata/android/de/images/phoneScreenshots/07.jpg b/fastlane/metadata/android/de/images/phoneScreenshots/07.jpg new file mode 100644 index 00000000..0cfd3dfc Binary files /dev/null and b/fastlane/metadata/android/de/images/phoneScreenshots/07.jpg differ diff --git a/fastlane/metadata/android/de/images/tenInchScreenshots/00.jpg b/fastlane/metadata/android/de/images/tenInchScreenshots/00.jpg index 129d9213..540ea213 100644 Binary files a/fastlane/metadata/android/de/images/tenInchScreenshots/00.jpg and b/fastlane/metadata/android/de/images/tenInchScreenshots/00.jpg differ diff --git a/fastlane/metadata/android/de/images/tenInchScreenshots/01.jpg b/fastlane/metadata/android/de/images/tenInchScreenshots/01.jpg index b57be109..24c14ee3 100644 Binary files a/fastlane/metadata/android/de/images/tenInchScreenshots/01.jpg and b/fastlane/metadata/android/de/images/tenInchScreenshots/01.jpg differ diff --git a/fastlane/metadata/android/de/images/tenInchScreenshots/02.jpg b/fastlane/metadata/android/de/images/tenInchScreenshots/02.jpg index e4f32fa7..c492940c 100644 Binary files a/fastlane/metadata/android/de/images/tenInchScreenshots/02.jpg and b/fastlane/metadata/android/de/images/tenInchScreenshots/02.jpg differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/00.jpg b/fastlane/metadata/android/en-US/images/phoneScreenshots/00.jpg index 13c9ed58..1406ace4 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/00.jpg and b/fastlane/metadata/android/en-US/images/phoneScreenshots/00.jpg differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/01.jpg b/fastlane/metadata/android/en-US/images/phoneScreenshots/01.jpg index 621ac15c..a9302908 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/01.jpg and b/fastlane/metadata/android/en-US/images/phoneScreenshots/01.jpg differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/02.jpg b/fastlane/metadata/android/en-US/images/phoneScreenshots/02.jpg index 9aa918ea..d6a2225d 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/02.jpg and b/fastlane/metadata/android/en-US/images/phoneScreenshots/02.jpg differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/03.jpg b/fastlane/metadata/android/en-US/images/phoneScreenshots/03.jpg index 1406ace4..d813ceb7 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/03.jpg and b/fastlane/metadata/android/en-US/images/phoneScreenshots/03.jpg differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/04.jpg b/fastlane/metadata/android/en-US/images/phoneScreenshots/04.jpg index a9302908..598e0fb4 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/04.jpg and b/fastlane/metadata/android/en-US/images/phoneScreenshots/04.jpg differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/05.jpg b/fastlane/metadata/android/en-US/images/phoneScreenshots/05.jpg index e98e352d..1e0b4651 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/05.jpg and b/fastlane/metadata/android/en-US/images/phoneScreenshots/05.jpg differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/06.jpg b/fastlane/metadata/android/en-US/images/phoneScreenshots/06.jpg index 1ea361f4..e98e352d 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/06.jpg and b/fastlane/metadata/android/en-US/images/phoneScreenshots/06.jpg differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/07.jpg b/fastlane/metadata/android/en-US/images/phoneScreenshots/07.jpg new file mode 100644 index 00000000..328ff8f0 Binary files /dev/null and b/fastlane/metadata/android/en-US/images/phoneScreenshots/07.jpg differ diff --git a/fastlane/metadata/android/en-US/images/tenInchScreenshots/00.jpg b/fastlane/metadata/android/en-US/images/tenInchScreenshots/00.jpg index b56ac174..52caaada 100644 Binary files a/fastlane/metadata/android/en-US/images/tenInchScreenshots/00.jpg and b/fastlane/metadata/android/en-US/images/tenInchScreenshots/00.jpg differ diff --git a/fastlane/metadata/android/en-US/images/tenInchScreenshots/01.jpg b/fastlane/metadata/android/en-US/images/tenInchScreenshots/01.jpg index d85f0727..e31f4a4b 100644 Binary files a/fastlane/metadata/android/en-US/images/tenInchScreenshots/01.jpg and b/fastlane/metadata/android/en-US/images/tenInchScreenshots/01.jpg differ diff --git a/fastlane/metadata/android/en-US/images/tenInchScreenshots/02.jpg b/fastlane/metadata/android/en-US/images/tenInchScreenshots/02.jpg index 168c8f7d..b0c8d81c 100644 Binary files a/fastlane/metadata/android/en-US/images/tenInchScreenshots/02.jpg and b/fastlane/metadata/android/en-US/images/tenInchScreenshots/02.jpg differ