-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerate_screenshots.py
More file actions
1329 lines (1182 loc) · 52 KB
/
generate_screenshots.py
File metadata and controls
1329 lines (1182 loc) · 52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
"""
Remote Shutter Screenshot Generator
Generates localized SVG screenshots for different device sizes and languages.
Reads from SVG template files for better design control.
Exports PNG files at expected resolutions using rsvg-convert.
"""
import os
import json
import re
import subprocess
import sys
import platform
from pathlib import Path
# Device configurations
DEVICES = {
"iphone_67": {
"name": "iPhone 15 Pro Max",
"template_name": "iphone_15_pro_max",
"fastlane_family": "APP_IPHONE_67",
"width": 1290, "height": 2796,
},
"iphone_65": {
"name": "iPhone 15 Pro",
"template_name": "iphone_15_pro",
"fastlane_family": "APP_IPHONE_65",
"width": 1284, "height": 2778,
},
"ipad_pro_11": {
"name": "iPad Pro 11",
"template_name": "ipad_pro_11",
"fastlane_family": "APP_IPAD_PRO_3GEN_11",
"width": 1640, "height": 2360,
},
"ipad_pro_12_9": {
"name": "iPad Pro 12.9",
"template_name": "ipad_pro_12.9",
"fastlane_family": "APP_IPAD_PRO_3GEN_129",
"width": 2048, "height": 2732,
},
}
# Localization data
LOCALIZATIONS = {
"en": {
"screenshot1": {
"title": "Remote Shutter",
"subtitle": "Take pictures",
"description": "from anywhere.",
"feature": "Works from\nup to 50\nfeet away!"
},
"screenshot2": {
"title": "Remote Shutter",
"subtitle": "Take pictures",
"description": "from anywhere.",
"feature": "Works from\nup to 50\nfeet away!"
},
"screenshot3": {
"title": "Capture Memories",
"subtitle": "Just Like You",
"description": "Want Them",
"feature": "Perfect for\ncreative\nangles!"
},
"screenshot4": {
"title": "",
"subtitle": "",
"description": "",
"feature": "Connect Wirelessly\nDevice to Device\nNo Internet Required",
"camera": "Camera",
"remote": "Remote"
}
},
"it": {
"screenshot1": {
"title": "Remote Shutter",
"subtitle": "Scatta foto",
"description": "da ovunque.",
"feature": "Funziona fino a\n50 piedi\ndi distanza!"
},
"screenshot2": {
"title": "Remote Shutter",
"subtitle": "Scatta foto",
"description": "da ovunque.",
"feature": "Funziona fino a\n50 piedi\ndi distanza!"
},
"screenshot3": {
"title": "Cattura Ricordi",
"subtitle": "Proprio Come",
"description": "Li Vuoi",
"feature": "Perfetto per\nangoli\ncreativi!"
},
"screenshot4": {
"title": "", "subtitle": "", "description": "",
"feature": "Connessione Wireless\nDispositivo a Dispositivo\nNessun Internet Necessario",
"camera": "Camera",
"remote": "Controllo"
}
},
"fr": {
"screenshot1": {
"title": "Remote Shutter",
"subtitle": "Prenez des photos",
"description": "de n'importe où.",
"feature": "Fonctionne jusqu'à\n50 pieds\nde distance!"
},
"screenshot2": {
"title": "Remote Shutter",
"subtitle": "Prenez des photos",
"description": "de n'importe où.",
"feature": "Fonctionne jusqu'à\n50 pieds\nde distance!"
},
"screenshot3": {
"title": "Capturez des Souvenirs",
"subtitle": "Exactement Comme",
"description": "Vous Les Voulez",
"feature": "Parfait pour\ndes angles\ncréatifs!"
},
"screenshot4": {
"title": "", "subtitle": "", "description": "",
"feature": "Connexion Sans Fil\nAppareil à Appareil\nPas d'Internet Requis",
"camera": "Caméra",
"remote": "Télécommande"
}
},
"es": {
"screenshot1": {
"title": "Remote Shutter",
"subtitle": "Toma fotos",
"description": "desde cualquier lugar.",
"feature": "¡Funciona hasta\n50 pies\nde distancia!"
},
"screenshot2": {
"title": "Remote Shutter",
"subtitle": "Toma fotos",
"description": "desde cualquier lugar.",
"feature": "¡Funciona hasta\n50 pies\nde distancia!"
},
"screenshot3": {
"title": "Captura Recuerdos",
"subtitle": "Exactamente Como",
"description": "Los Quieres",
"feature": "¡Perfecto para\nángulos\ncreativos!"
},
"screenshot4": {
"title": "", "subtitle": "", "description": "",
"feature": "Conecta Sin Cables\nDispositivo a Dispositivo\nSin Internet Necesario",
"camera": "Cámara",
"remote": "Control"
}
},
"de": {
"screenshot1": {
"title": "Remote Shutter",
"subtitle": "Machen Sie Fotos",
"description": "von überall.",
"feature": "Funktioniert aus\nbis zu 15\nMetern Entfernung!"
},
"screenshot2": {
"title": "Remote Shutter",
"subtitle": "Machen Sie Fotos",
"description": "von überall.",
"feature": "Funktioniert aus\nbis zu 15\nMetern Entfernung!"
},
"screenshot3": {
"title": "Erinnerungen",
"subtitle": "Genau So",
"description": "Festhalten",
"feature": "Perfekt für\nkreative\nBlickwinkel!"
},
"screenshot4": {
"title": "", "subtitle": "", "description": "",
"feature": "Kabellos Verbinden\nGerät zu Gerät\nKein Internet Nötig",
"camera": "Kamera",
"remote": "Fernbedienung"
}
},
"pt": {
"screenshot1": {
"title": "Remote Shutter",
"subtitle": "Tire fotos",
"description": "de qualquer lugar.",
"feature": "Funciona até\n50 pés\nde distância!"
},
"screenshot2": {
"title": "Remote Shutter",
"subtitle": "Tire fotos",
"description": "de qualquer lugar.",
"feature": "Funciona até\n50 pés\nde distância!"
},
"screenshot3": {
"title": "Capture Memórias",
"subtitle": "Exatamente Como",
"description": "Você As Quer",
"feature": "Perfeito para\nângulos\ncriativos!"
},
"screenshot4": {
"title": "", "subtitle": "", "description": "",
"feature": "Conecte Sem Fio\nDispositivo a Dispositivo\nSem Internet Necessária",
"camera": "Câmera",
"remote": "Controle"
}
},
"da": {
"screenshot1": {
"title": "Remote Shutter",
"subtitle": "Tag billeder",
"description": "fra hvor som helst.",
"feature": "Virker op til\n50 fod\nvæk!"
},
"screenshot2": {
"title": "Remote Shutter",
"subtitle": "Tag billeder",
"description": "fra hvor som helst.",
"feature": "Virker op til\n50 fod\nvæk!"
},
"screenshot3": {
"title": "Fang Minder",
"subtitle": "Præcis Som Du",
"description": "Vil Have Dem",
"feature": "Perfekt til\nkreative\nvinkler!"
},
"screenshot4": {
"title": "", "subtitle": "", "description": "",
"feature": "Trådløs Forbindelse\nEnhed til Enhed\nIntet Internet Påkrævet",
"camera": "Kamera",
"remote": "Remote"
}
},
"ja": {
"screenshot1": {
"title": "Remote Shutter",
"subtitle": "どこからでも",
"description": "撮影できる",
"feature": "最大15メートル\n離れた場所から\n撮影可能!"
},
"screenshot2": {
"title": "Remote Shutter",
"subtitle": "どこからでも",
"description": "撮影できる",
"feature": "最大15メートル\n離れた場所から\n撮影可能!"
},
"screenshot3": {
"title": "思い出を",
"subtitle": "思い通りに",
"description": "残そう",
"feature": "自由な\nアングルで\n撮影!"
},
"screenshot4": {
"title": "", "subtitle": "", "description": "",
"feature": "ワイヤレス接続\nデバイス同士を直接\nネット不要",
"camera": "カメラ",
"remote": "リモコン"
}
},
"ko": {
"screenshot1": {
"title": "Remote Shutter",
"subtitle": "어디서든",
"description": "촬영하세요",
"feature": "최대 15미터\n떨어진 곳에서\n촬영 가능!"
},
"screenshot2": {
"title": "Remote Shutter",
"subtitle": "어디서든",
"description": "촬영하세요",
"feature": "최대 15미터\n떨어진 곳에서\n촬영 가능!"
},
"screenshot3": {
"title": "추억을",
"subtitle": "원하는 대로",
"description": "담아보세요",
"feature": "자유로운\n각도로\n촬영!"
},
"screenshot4": {
"title": "", "subtitle": "", "description": "",
"feature": "무선 연결\n기기 간 직접 연결\n인터넷 불필요",
"camera": "카메라",
"remote": "리모컨"
}
},
"zh-Hans": {
"screenshot1": {
"title": "Remote Shutter",
"subtitle": "随时随地",
"description": "拍照",
"feature": "最远可达\n15米\n远程拍摄!"
},
"screenshot2": {
"title": "Remote Shutter",
"subtitle": "随时随地",
"description": "拍照",
"feature": "最远可达\n15米\n远程拍摄!"
},
"screenshot3": {
"title": "记录美好",
"subtitle": "随心所欲",
"description": "留住回忆",
"feature": "自由角度\n创意\n拍摄!"
},
"screenshot4": {
"title": "", "subtitle": "", "description": "",
"feature": "无线连接\n设备直连\n无需网络",
"camera": "相机",
"remote": "遥控"
}
}
}
# Map script language codes to fastlane locale directory names
LANG_TO_LOCALE = {
"en": "en-US",
"es": "es-MX",
"fr": "fr-FR",
"da": "da",
"it": "it",
"pt": "pt-BR",
"de": "de-DE",
"ja": "ja",
"ko": "ko",
"zh-Hans": "zh-Hans",
}
def detect_package_manager():
"""Detect the appropriate package manager for the current system"""
system = platform.system().lower()
if system == "darwin": # macOS
# Check if Homebrew is available
try:
subprocess.run(["brew", "--version"], capture_output=True, check=True)
return "brew"
except (subprocess.CalledProcessError, FileNotFoundError):
print("⚠️ Homebrew not found. Please install it first:")
print(" /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"")
return None
elif system == "linux":
# Check for apt (Debian/Ubuntu)
try:
subprocess.run(["apt", "--version"], capture_output=True, check=True)
return "apt"
except (subprocess.CalledProcessError, FileNotFoundError):
# Check for yum (RHEL/CentOS)
try:
subprocess.run(["yum", "--version"], capture_output=True, check=True)
return "yum"
except (subprocess.CalledProcessError, FileNotFoundError):
print("⚠️ Unsupported Linux distribution. Please install librsvg manually.")
return None
elif system == "windows":
# Check for Chocolatey
try:
subprocess.run(["choco", "--version"], capture_output=True, check=True)
return "choco"
except (subprocess.CalledProcessError, FileNotFoundError):
print("⚠️ Chocolatey not found. Please install it first:")
print(" Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))")
return None
return None
def install_rsvg_convert():
"""Install rsvg-convert using the appropriate package manager"""
package_manager = detect_package_manager()
if not package_manager:
print("❌ Could not detect package manager. Please install librsvg manually:")
print(" macOS: brew install librsvg")
print(" Ubuntu/Debian: sudo apt install librsvg2-bin")
print(" Windows: choco install librsvg")
return False
print(f"🔧 Installing librsvg using {package_manager}...")
try:
if package_manager == "brew":
subprocess.run(["brew", "install", "librsvg"], check=True)
elif package_manager == "apt":
subprocess.run(["sudo", "apt", "update"], check=True)
subprocess.run(["sudo", "apt", "install", "-y", "librsvg2-bin"], check=True)
elif package_manager == "yum":
subprocess.run(["sudo", "yum", "install", "-y", "librsvg2"], check=True)
elif package_manager == "choco":
subprocess.run(["choco", "install", "librsvg", "-y"], check=True)
print("✅ librsvg installed successfully!")
return True
except subprocess.CalledProcessError as e:
print(f"❌ Failed to install librsvg: {e}")
print("Please install it manually:")
print(" macOS: brew install librsvg")
print(" Ubuntu/Debian: sudo apt install librsvg2-bin")
print(" Windows: choco install librsvg")
return False
def check_rsvg_convert():
"""Check if rsvg-convert is available"""
try:
subprocess.run(["rsvg-convert", "--version"], capture_output=True, check=True)
return True
except (subprocess.CalledProcessError, FileNotFoundError):
return False
def check_inkscape():
"""Check if Inkscape is available"""
# Check common Inkscape locations
inkscape_paths = [
"inkscape", # If in PATH
"/Applications/Inkscape.app/Contents/MacOS/inkscape", # macOS app
"/usr/bin/inkscape", # Linux
"/opt/homebrew/bin/inkscape", # Homebrew
]
for path in inkscape_paths:
try:
subprocess.run([path, "--version"], capture_output=True, check=True)
return path
except (subprocess.CalledProcessError, FileNotFoundError):
continue
return None
def convert_svg_to_png_inkscape(svg_file, png_file, width, height):
"""Convert SVG to PNG using Inkscape"""
inkscape_path = check_inkscape()
if not inkscape_path:
return False
try:
cmd = [
inkscape_path,
"--export-type=png",
f"--export-width={width}",
f"--export-height={height}",
f"--export-background=black",
f"--export-filename={png_file}",
str(svg_file)
]
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode == 0:
print(f"✅ Converted with Inkscape: {png_file.name}")
return True
else:
print(f"❌ Inkscape failed to convert {svg_file.name}: {result.stderr}")
return False
except Exception as e:
print(f"❌ Error converting with Inkscape {svg_file.name}: {e}")
return False
def convert_svg_to_png(svg_file, png_file, width, height):
"""Convert SVG to PNG using rsvg-convert with Inkscape fallback"""
try:
cmd = [
"rsvg-convert",
"--width", str(width),
"--height", str(height),
"--background-color=black",
"--format", "png",
"--output", str(png_file),
str(svg_file)
]
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode == 0:
print(f"✅ Converted: {png_file.name}")
return True
else:
# rsvg-convert failed, try Inkscape as fallback
print(f"⚠️ rsvg-convert failed, trying Inkscape...")
if check_inkscape():
return convert_svg_to_png_inkscape(svg_file, png_file, width, height)
else:
print(f"❌ Failed to convert {svg_file.name}: {result.stderr}")
print(" Install Inkscape for better SVG compatibility")
return False
except Exception as e:
print(f"❌ Error converting {svg_file.name}: {e}")
# Try Inkscape as fallback
if check_inkscape():
return convert_svg_to_png_inkscape(svg_file, png_file, width, height)
return False
def ensure_rsvg_convert():
"""Ensure rsvg-convert is available, install if needed"""
if check_rsvg_convert():
return True
print("⚠️ rsvg-convert not found. Attempting to install...")
# Ask user for permission
response = input("Do you want to install librsvg automatically? (y/N): ").strip().lower()
if response not in ['y', 'yes']:
print("📄 PNG conversion will be skipped. Only SVG files will be generated.")
return False
return install_rsvg_convert()
def load_svg_template(template_name, device):
"""Load SVG template file and return its content"""
template_dir = Path("svg_templates")
template_file = template_dir / f"{template_name}_{device['name'].lower().replace(' ', '_')}.svg"
if not template_file.exists():
raise FileNotFoundError(f"SVG template not found: {template_file}")
with open(template_file, 'r', encoding='utf-8') as f:
return f.read()
def validate_svg_file(svg_file):
"""Validate SVG file and return True if valid"""
try:
with open(svg_file, 'r', encoding='utf-8') as f:
content = f.read()
# Basic SVG validation
if not content.strip().startswith('<?xml'):
return False, "Missing XML declaration"
if '<svg' not in content:
return False, "Missing SVG root element"
if '</svg>' not in content:
return False, "Missing closing SVG tag"
# Check for mismatched tags (more reliable corruption indicator)
if content.count('<svg') != content.count('</svg>'):
return False, "Mismatched SVG tags"
# Check for obvious XML syntax errors
if content.count('<') != content.count('>'):
return False, "Mismatched XML tags"
return True, "Valid SVG"
except Exception as e:
return False, f"Error reading SVG: {e}"
def replace_text_in_svg(svg_content, lang, screenshot_type):
"""Replace placeholder text in SVG with localized content"""
local_data = LOCALIZATIONS[lang][screenshot_type]
# Replace various placeholder patterns
replacements = {
r'{{TITLE}}': local_data['title'],
r'{{SUBTITLE}}': local_data['subtitle'],
r'{{DESCRIPTION}}': local_data['description'],
r'{{FEATURE}}': local_data['feature'],
r'{{FEATURE_LINE1}}': local_data['feature'].split('\n')[0],
r'{{FEATURE_LINE2}}': local_data['feature'].split('\n')[1] if len(local_data['feature'].split('\n')) > 1 else '',
r'{{FEATURE_LINE3}}': local_data['feature'].split('\n')[2] if len(local_data['feature'].split('\n')) > 2 else '',
}
# Apply replacements
for placeholder, replacement in replacements.items():
svg_content = re.sub(placeholder, replacement, svg_content)
return svg_content
def generate_svg_from_template(device_config, lang, screenshot_type, svg_work_dir, fastlane_dir, locale, png_enabled):
"""Generate SVG from template for specific device, language, and screenshot type.
SVG intermediates go to svg_work_dir/<lang>/<device>/.
PNGs go to fastlane_dir/<locale>/ with fastlane naming.
"""
# Create SVG working directory (for intermediates)
lang_dir = svg_work_dir / lang
lang_dir.mkdir(exist_ok=True)
device_dir = lang_dir / device_config['name'].lower().replace(' ', '_')
device_dir.mkdir(exist_ok=True)
# Load template using template_name field
template_name = f"{screenshot_type}_{device_config['template_name']}.svg"
template_path = Path("svg_templates") / template_name
if not template_path.exists():
print(f"❌ Template not found: {template_path}")
return False
# Load localization data
lang_file = Path("localization") / f"{lang}.json"
if not lang_file.exists():
print(f"❌ Localization file not found: {lang_file}")
return False
with open(lang_file, 'r', encoding='utf-8') as f:
lang_data = json.load(f)
# Load template content
with open(template_path, 'r', encoding='utf-8') as f:
template_content = f.read()
# Replace placeholders
if screenshot_type == "screenshot1":
replacements = {
"{{TITLE}}": lang_data.get(screenshot_type, {}).get("title", ""),
"{{SUBTITLE}}": lang_data.get(screenshot_type, {}).get("subtitle", ""),
"{{DESCRIPTION}}": lang_data.get(screenshot_type, {}).get("description", "")
}
elif screenshot_type == "screenshot4":
feature_lines = lang_data.get(screenshot_type, {}).get("feature", "").split('\n')
replacements = {
"{{FEATURE_LINE1}}": feature_lines[0] if len(feature_lines) > 0 else "",
"{{FEATURE_LINE2}}": feature_lines[1] if len(feature_lines) > 1 else "",
"{{FEATURE_LINE3}}": feature_lines[2] if len(feature_lines) > 2 else "",
"{{FEATURE_LINE4}}": feature_lines[3] if len(feature_lines) > 3 else "",
"{{FEATURE}}": lang_data.get(screenshot_type, {}).get("feature", ""),
"{{CAMERA}}": lang_data.get(screenshot_type, {}).get("camera", "Camera"),
"{{REMOTE}}": lang_data.get(screenshot_type, {}).get("remote", "Remote")
}
else:
feature_lines = lang_data.get(screenshot_type, {}).get("feature", "").split('\n')
replacements = {
"{{FEATURE_LINE1}}": feature_lines[0] if len(feature_lines) > 0 else "",
"{{FEATURE_LINE2}}": feature_lines[1] if len(feature_lines) > 1 else "",
"{{FEATURE_LINE3}}": feature_lines[2] if len(feature_lines) > 2 else "",
"{{FEATURE}}": lang_data.get(screenshot_type, {}).get("feature", "")
}
# Apply replacements
for placeholder, value in replacements.items():
template_content = template_content.replace(placeholder, value)
# Write SVG intermediate
svg_filename = f"{screenshot_type}_{lang}.svg"
svg_path = device_dir / svg_filename
with open(svg_path, 'w', encoding='utf-8') as f:
f.write(template_content)
print(f"Generated SVG: {svg_path}")
# Convert to PNG with fastlane naming
if png_enabled:
# screenshot1 -> index 0, screenshot2 -> index 1, etc.
screenshot_index = int(screenshot_type.replace("screenshot", "")) - 1
fastlane_family = device_config['fastlane_family']
# Fastlane naming: <index>_<DEVICE_FAMILY>_<index>.png
png_filename = f"{screenshot_index}_{fastlane_family}_{screenshot_index}.png"
locale_dir = fastlane_dir / locale
locale_dir.mkdir(parents=True, exist_ok=True)
png_path = locale_dir / png_filename
if convert_svg_to_png(svg_path, png_path, device_config['width'], device_config['height']):
print(f"✅ PNG: {png_path}")
return True
else:
print(f"⚠️ PNG conversion failed for {svg_filename}")
return False
return True
def generate_all_screenshots():
"""Generate all screenshots for all devices and languages.
SVG intermediates go to screenshots/.
PNGs go to fastlane/screenshots/<locale>/ with fastlane naming.
"""
# SVG working directory (intermediates)
svg_work_dir = Path("screenshots")
svg_work_dir.mkdir(exist_ok=True)
# Fastlane output directory
fastlane_dir = Path("fastlane") / "screenshots"
fastlane_dir.mkdir(parents=True, exist_ok=True)
# Create locale subdirectories
for lang, locale in LANG_TO_LOCALE.items():
(fastlane_dir / locale).mkdir(exist_ok=True)
# Create templates directory if it doesn't exist
templates_dir = Path("svg_templates")
templates_dir.mkdir(exist_ok=True)
print("🎨 Generating Remote Shutter Screenshots...")
print(f"📁 SVG working directory: {svg_work_dir.absolute()}")
print(f"📁 PNG output directory: {fastlane_dir.absolute()}")
print(f"📁 Templates directory: {templates_dir.absolute()}")
print()
# Check and ensure converter availability
png_enabled = ensure_rsvg_convert()
inkscape_available = check_inkscape() is not None
if png_enabled:
print("✅ rsvg-convert found - PNG conversion enabled")
if inkscape_available:
print("✅ Inkscape found - will be used as fallback if rsvg-convert fails")
elif inkscape_available:
print("✅ Inkscape found - PNG conversion enabled")
png_enabled = True
else:
print("⚠️ No SVG converters found - only SVG files will be generated")
print(" Install rsvg-convert or Inkscape for PNG conversion")
print()
# Check if templates exist
if not list(templates_dir.glob("*.svg")):
print("⚠️ No SVG templates found!")
print("📝 Please create SVG template files in the 'svg_templates' directory:")
print(" - screenshot1_iphone_15_pro_max.svg")
print(" - screenshot1_iphone_15_pro.svg")
print(" - screenshot1_ipad_pro_11.svg")
print(" - screenshot2_iphone_15_pro_max.svg")
print(" - screenshot2_iphone_15_pro.svg")
print(" - screenshot2_ipad_pro_11.svg")
print(" - screenshot3_iphone_15_pro_max.svg")
print(" - screenshot3_iphone_15_pro.svg")
print(" - screenshot3_ipad_pro_11.svg")
print(" - screenshot4_iphone_15_pro_max.svg")
print(" - screenshot4_iphone_15_pro.svg")
print(" - screenshot4_ipad_pro_11.svg")
print()
print("🔧 Template placeholders:")
print(" {{TITLE}} - App title")
print(" {{SUBTITLE}} - Subtitle text")
print(" {{DESCRIPTION}} - Description text")
print(" {{FEATURE}} - Full feature text")
print(" {{FEATURE_LINE1}} - First line of feature text")
print(" {{FEATURE_LINE2}} - Second line of feature text")
print(" {{FEATURE_LINE3}} - Third line of feature text")
return
total_screenshots = len(DEVICES) * len(LOCALIZATIONS) * 4
current = 0
for lang in LOCALIZATIONS.keys():
locale = LANG_TO_LOCALE[lang]
print(f"🌍 Language: {lang} (locale: {locale})")
for device_name, device_config in DEVICES.items():
print(f" 📱 Device: {device_config['name']} ({device_config['fastlane_family']})")
for i in range(1, 5):
screenshot_type = f"screenshot{i}"
generate_svg_from_template(
device_config, lang, screenshot_type,
svg_work_dir, fastlane_dir, locale, png_enabled
)
current += 1
print(f" ✅ Generated 4 screenshots ({current}/{total_screenshots})")
print()
print("🎉 All screenshots generated successfully!")
print(f"📊 Total screenshots: {total_screenshots}")
print(f"📱 Devices: {len(DEVICES)}")
print(f"🌍 Languages: {len(LOCALIZATIONS)}")
print(f"🖼️ Screenshots per device/language: 4")
if png_enabled:
print(f"📄 Format: SVG (working) + PNG (fastlane)")
print(f"📏 PNG resolutions:")
for device_name, device_config in DEVICES.items():
print(f" - {device_config['name']} ({device_config['fastlane_family']}): {device_config['width']} x {device_config['height']}")
else:
print(f"📄 Format: SVG only (install rsvg-convert or Inkscape for PNG conversion)")
print()
print("📁 Fastlane directory structure:")
print(" fastlane/screenshots/")
for lang, locale in LANG_TO_LOCALE.items():
print(f" ├── {locale}/")
for device_name, device_config in DEVICES.items():
family = device_config['fastlane_family']
for i in range(5):
print(f" │ ├── {i}_{family}_{i}.png")
def create_localization_files():
"""Create JSON files for each language for easy editing"""
loc_dir = Path("localization")
loc_dir.mkdir(exist_ok=True)
for lang, data in LOCALIZATIONS.items():
filename = f"{lang}.json"
filepath = loc_dir / filename
with open(filepath, 'w', encoding='utf-8') as f:
json.dump(data, f, indent=2, ensure_ascii=False)
print(f"📝 Created localization file: {filename}")
def create_sample_templates():
"""Create sample SVG template files for each device resolution if they don't exist"""
templates_dir = Path("svg_templates")
templates_dir.mkdir(exist_ok=True)
# Define all required template files
required_templates = [
"screenshot1_iphone_15_pro_max.svg",
"screenshot2_iphone_15_pro_max.svg",
"screenshot3_iphone_15_pro_max.svg",
"screenshot4_iphone_15_pro_max.svg",
"screenshot1_iphone_15_pro.svg",
"screenshot2_iphone_15_pro.svg",
"screenshot3_iphone_15_pro.svg",
"screenshot4_iphone_15_pro.svg",
"screenshot1_ipad_pro_11.svg",
"screenshot2_ipad_pro_11.svg",
"screenshot3_ipad_pro_11.svg",
"screenshot4_ipad_pro_11.svg",
"screenshot1_ipad_pro_12.9.svg",
"screenshot2_ipad_pro_12.9.svg",
"screenshot3_ipad_pro_12.9.svg",
"screenshot4_ipad_pro_12.9.svg"
]
# Check which templates already exist
existing_templates = []
missing_templates = []
for template in required_templates:
template_path = templates_dir / template
if template_path.exists():
existing_templates.append(template)
else:
missing_templates.append(template)
# If all templates exist, don't overwrite them
if not missing_templates:
print("📁 SVG templates already exist - preserving your custom designs")
print(" If you want to regenerate templates, delete the svg_templates/ directory first")
return
# If some templates exist, warn user
if existing_templates:
print("⚠️ Some SVG templates already exist:")
for template in existing_templates:
print(f" ✅ {template}")
print(" These will be preserved. Only missing templates will be created.")
print()
# Create only missing templates
print("📝 Creating missing SVG templates...")
# iPhone 15 Pro Max (1290 x 2796)
iphone_max_template1 = '''<?xml version="1.0" encoding="UTF-8"?>
<svg width="1290" height="2796" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="greenGradient" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#4CAF50;stop-opacity:1" />
<stop offset="100%" style="stop-color:#2E7D32;stop-opacity:1" />
</linearGradient>
</defs>
<!-- Background -->
<rect width="1290" height="2796" fill="url(#greenGradient)"/>
<!-- Main Text - iPhone 15 Pro Max positioning -->
<text x="322" y="839" font-family="Arial, sans-serif" font-size="86"
font-weight="bold" fill="white">
<tspan x="322" dy="0">{{TITLE}}</tspan>
<tspan x="322" dy="107" font-size="103">{{SUBTITLE}}</tspan>
<tspan x="322" dy="129" font-size="103">{{DESCRIPTION}}</tspan>
</text>
<!-- Device mockup - iPhone 15 Pro Max proportions -->
<g transform="translate(774,839) rotate(-15)">
<rect x="0" y="0" width="516" height="929" rx="20" ry="20"
fill="#1a1a1a" stroke="#333" stroke-width="2"/>
<rect x="8" y="8" width="500" height="913" rx="15" ry="15"
fill="#87CEEB"/>
</g>
</svg>'''
iphone_max_template2 = '''<?xml version="1.0" encoding="UTF-8"?>
<svg width="1290" height="2796" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="greenGradient2" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#4CAF50;stop-opacity:1" />
<stop offset="100%" style="stop-color:#2E7D32;stop-opacity:1" />
</linearGradient>
</defs>
<!-- Background -->
<rect width="1290" height="2796" fill="url(#greenGradient2)"/>
<!-- Device mockup - iPhone 15 Pro Max proportions -->
<g transform="translate(129,1677) rotate(-15)">
<rect x="0" y="0" width="425" height="766" rx="20" ry="20"
fill="#1a1a1a" stroke="#333" stroke-width="2"/>
<rect x="8" y="8" width="409" height="750" rx="15" ry="15"
fill="#87CEEB"/>
</g>
<!-- Feature Text - iPhone 15 Pro Max positioning -->
<text x="774" y="559" font-family="Arial, sans-serif" font-size="64"
font-weight="bold" fill="white" text-anchor="middle">
<tspan x="774" dy="0">{{FEATURE_LINE1}}</tspan>
<tspan x="774" dy="86">{{FEATURE_LINE2}}</tspan>
<tspan x="774" dy="86">{{FEATURE_LINE3}}</tspan>
</text>
</svg>'''
# iPhone 15 Pro (1284 x 2778)
iphone_template1 = '''<?xml version="1.0" encoding="UTF-8"?>
<svg width="1284" height="2778" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="greenGradient" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#4CAF50;stop-opacity:1" />
<stop offset="100%" style="stop-color:#2E7D32;stop-opacity:1" />
</linearGradient>
</defs>
<!-- Background -->
<rect width="1284" height="2778" fill="url(#greenGradient)"/>
<!-- Main Text - iPhone 15 Pro positioning -->
<text x="321" y="833" font-family="Arial, sans-serif" font-size="86"
font-weight="bold" fill="white">
<tspan x="321" dy="0">{{TITLE}}</tspan>
<tspan x="321" dy="107" font-size="103">{{SUBTITLE}}</tspan>
<tspan x="321" dy="129" font-size="103">{{DESCRIPTION}}</tspan>
</text>
<!-- Device mockup - iPhone 15 Pro proportions -->
<g transform="translate(770,833) rotate(-15)">
<rect x="0" y="0" width="514" height="925" rx="20" ry="20"
fill="#1a1a1a" stroke="#333" stroke-width="2"/>
<rect x="8" y="8" width="498" height="909" rx="15" ry="15"
fill="#87CEEB"/>
</g>
</svg>'''
iphone_template2 = '''<?xml version="1.0" encoding="UTF-8"?>
<svg width="1284" height="2778" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="greenGradient2" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#4CAF50;stop-opacity:1" />
<stop offset="100%" style="stop-color:#2E7D32;stop-opacity:1" />
</linearGradient>
</defs>
<!-- Background -->
<rect width="1284" height="2778" fill="url(#greenGradient2)"/>
<!-- Device mockup - iPhone 15 Pro proportions -->
<g transform="translate(128,1667) rotate(-15)">
<rect x="0" y="0" width="423" height="762" rx="20" ry="20"
fill="#1a1a1a" stroke="#333" stroke-width="2"/>
<rect x="8" y="8" width="407" height="746" rx="15" ry="15"
fill="#87CEEB"/>
</g>
<!-- Feature Text - iPhone 15 Pro positioning -->
<text x="770" y="555" font-family="Arial, sans-serif" font-size="64"
font-weight="bold" fill="white" text-anchor="middle">
<tspan x="770" dy="0">{{FEATURE_LINE1}}</tspan>
<tspan x="770" dy="86">{{FEATURE_LINE2}}</tspan>
<tspan x="770" dy="86">{{FEATURE_LINE3}}</tspan>
</text>
</svg>'''
# iPad Pro 11" (1640 x 2360)
ipad_template1 = '''<?xml version="1.0" encoding="UTF-8"?>
<svg width="1640" height="2360" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="greenGradient" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#4CAF50;stop-opacity:1" />
<stop offset="100%" style="stop-color:#2E7D32;stop-opacity:1" />
</linearGradient>
</defs>
<!-- Background -->
<rect width="1640" height="2360" fill="url(#greenGradient)"/>
<!-- Main Text - iPad Pro 11" positioning -->
<text x="410" y="708" font-family="Arial, sans-serif" font-size="110"
font-weight="bold" fill="white">
<tspan x="410" dy="0">{{TITLE}}</tspan>
<tspan x="410" dy="137" font-size="132">{{SUBTITLE}}</tspan>
<tspan x="410" dy="165" font-size="132">{{DESCRIPTION}}</tspan>
</text>
<!-- Device mockup - iPad Pro 11" proportions -->
<g transform="translate(987,708) rotate(-15)">
<rect x="0" y="0" width="656" height="944" rx="20" ry="20"
fill="#1a1a1a" stroke="#333" stroke-width="2"/>
<rect x="8" y="8" width="640" height="928" rx="15" ry="15"
fill="#87CEEB"/>
</g>
</svg>'''
ipad_template2 = '''<?xml version="1.0" encoding="UTF-8"?>
<svg width="1640" height="2360" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="greenGradient2" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#4CAF50;stop-opacity:1" />
<stop offset="100%" style="stop-color:#2E7D32;stop-opacity:1" />
</linearGradient>
</defs>
<!-- Background -->