@@ -45,7 +45,7 @@ export class AssetsGenerationService implements IAssetsGenerationService {
45
45
)
46
46
. map ( ( assetGroup : IAssetGroup ) =>
47
47
_ . filter ( assetGroup , ( assetSubGroup : IAssetSubGroup , imageTypeKey : string ) =>
48
- assetSubGroup && propertiesToEnumerate . indexOf ( imageTypeKey ) !== - 1 && assetSubGroup [ imageTypeKey ]
48
+ assetSubGroup && propertiesToEnumerate . indexOf ( imageTypeKey ) !== - 1
49
49
)
50
50
)
51
51
. flatten < IAssetSubGroup > ( )
@@ -57,26 +57,33 @@ export class AssetsGenerationService implements IAssetsGenerationService {
57
57
for ( const assetItem of assetItems ) {
58
58
const operation = assetItem . resizeOperation || Operations . Resize ;
59
59
let tempScale : number = null ;
60
- if ( assetItem . scale && ! _ . isNumber ( assetItem . scale ) ) {
61
- const splittedElements = `${ assetItem . scale } ` . split ( AssetConstants . sizeDelimiter ) ;
62
- tempScale = splittedElements && splittedElements . length && splittedElements [ 0 ] && + splittedElements [ 0 ] ;
60
+ if ( assetItem . scale ) {
61
+ if ( _ . isNumber ( assetItem . scale ) ) {
62
+ tempScale = assetItem . scale ;
63
+ } else {
64
+ const splittedElements = `${ assetItem . scale } ` . split ( AssetConstants . sizeDelimiter ) ;
65
+ tempScale = splittedElements && splittedElements . length && splittedElements [ 0 ] && + splittedElements [ 0 ] ;
66
+ }
63
67
}
64
68
65
- const scale = tempScale || 0.8 ;
69
+ const scale = tempScale || 1 ;
66
70
67
71
const outputPath = assetItem . path ;
72
+ const width = assetItem . width * scale ;
73
+ const height = assetItem . height * scale ;
68
74
69
75
switch ( operation ) {
70
76
case Operations . OverlayWith :
71
- const imageResize = Math . round ( Math . min ( assetItem . width , assetItem . height ) * scale ) ;
77
+ const overlayImageScale = assetItem . overlayImageScale || 0.8 ;
78
+ const imageResize = Math . round ( Math . min ( width , height ) * overlayImageScale ) ;
72
79
const image = await this . resize ( generationData . imagePath , imageResize , imageResize ) ;
73
- await this . generateImage ( generationData . background , assetItem . width , assetItem . height , outputPath , image ) ;
80
+ await this . generateImage ( generationData . background , width , height , outputPath , image ) ;
74
81
break ;
75
82
case Operations . Blank :
76
- await this . generateImage ( generationData . background , assetItem . width , assetItem . height , outputPath ) ;
83
+ await this . generateImage ( generationData . background , width , height , outputPath ) ;
77
84
break ;
78
85
case Operations . Resize :
79
- const resizedImage = await this . resize ( generationData . imagePath , assetItem . width , assetItem . height ) ;
86
+ const resizedImage = await this . resize ( generationData . imagePath , width , height ) ;
80
87
resizedImage . write ( outputPath ) ;
81
88
break ;
82
89
default :
0 commit comments