@@ -71,24 +71,30 @@ export class AssetsGenerationService implements IAssetsGenerationService {
71
71
const outputPath = assetItem . path ;
72
72
const width = assetItem . width * scale ;
73
73
const height = assetItem . height * scale ;
74
-
74
+ let image : Jimp ;
75
75
switch ( operation ) {
76
76
case Operations . OverlayWith :
77
77
const overlayImageScale = assetItem . overlayImageScale || AssetConstants . defaultOverlayImageScale ;
78
78
const imageResize = Math . round ( Math . min ( width , height ) * overlayImageScale ) ;
79
- const image = await this . resize ( generationData . imagePath , imageResize , imageResize ) ;
80
- await this . generateImage ( generationData . background , width , height , outputPath , image ) ;
79
+ image = await this . resize ( generationData . imagePath , imageResize , imageResize ) ;
80
+ image = this . generateImage ( generationData . background , width , height , outputPath , image ) ;
81
81
break ;
82
82
case Operations . Blank :
83
- await this . generateImage ( generationData . background , width , height , outputPath ) ;
83
+ image = this . generateImage ( generationData . background , width , height , outputPath ) ;
84
84
break ;
85
85
case Operations . Resize :
86
- const resizedImage = await this . resize ( generationData . imagePath , width , height ) ;
87
- resizedImage . write ( outputPath ) ;
86
+ image = await this . resize ( generationData . imagePath , width , height ) ;
88
87
break ;
89
88
default :
90
89
throw new Error ( `Invalid image generation operation: ${ operation } ` ) ;
91
90
}
91
+
92
+ // This code disables the alpha chanel, as some images for the Apple App Store must not have transparency.
93
+ if ( assetItem . rgba === false ) {
94
+ image = image . rgba ( false ) ;
95
+ }
96
+
97
+ image . write ( outputPath ) ;
92
98
}
93
99
}
94
100
@@ -97,7 +103,7 @@ export class AssetsGenerationService implements IAssetsGenerationService {
97
103
return image . scaleToFit ( width , height ) ;
98
104
}
99
105
100
- private generateImage ( background : string , width : number , height : number , outputPath : string , overlayImage ?: Jimp ) : void {
106
+ private generateImage ( background : string , width : number , height : number , outputPath : string , overlayImage ?: Jimp ) : Jimp {
101
107
// Typescript declarations for Jimp are not updated to define the constructor with backgroundColor so we workaround it by casting it to <any> for this case only.
102
108
const J = < any > Jimp ;
103
109
const backgroundColor = this . getRgbaNumber ( background ) ;
@@ -109,7 +115,7 @@ export class AssetsGenerationService implements IAssetsGenerationService {
109
115
image = image . composite ( overlayImage , centeredWidth , centeredHeight ) ;
110
116
}
111
117
112
- image . write ( outputPath ) ;
118
+ return image ;
113
119
}
114
120
115
121
private getRgbaNumber ( colorString : string ) : number {
0 commit comments