@@ -71,24 +71,30 @@ export class AssetsGenerationService implements IAssetsGenerationService {
7171 const outputPath = assetItem . path ;
7272 const width = assetItem . width * scale ;
7373 const height = assetItem . height * scale ;
74-
74+ let image : Jimp ;
7575 switch ( operation ) {
7676 case Operations . OverlayWith :
7777 const overlayImageScale = assetItem . overlayImageScale || AssetConstants . defaultOverlayImageScale ;
7878 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 ) ;
8181 break ;
8282 case Operations . Blank :
83- await this . generateImage ( generationData . background , width , height , outputPath ) ;
83+ image = this . generateImage ( generationData . background , width , height , outputPath ) ;
8484 break ;
8585 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 ) ;
8887 break ;
8988 default :
9089 throw new Error ( `Invalid image generation operation: ${ operation } ` ) ;
9190 }
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 ) ;
9298 }
9399 }
94100
@@ -97,7 +103,7 @@ export class AssetsGenerationService implements IAssetsGenerationService {
97103 return image . scaleToFit ( width , height ) ;
98104 }
99105
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 {
101107 // 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.
102108 const J = < any > Jimp ;
103109 const backgroundColor = this . getRgbaNumber ( background ) ;
@@ -109,7 +115,7 @@ export class AssetsGenerationService implements IAssetsGenerationService {
109115 image = image . composite ( overlayImage , centeredWidth , centeredHeight ) ;
110116 }
111117
112- image . write ( outputPath ) ;
118+ return image ;
113119 }
114120
115121 private getRgbaNumber ( colorString : string ) : number {
0 commit comments