@@ -22,7 +22,6 @@ type GetOptimizeResultProps = {
22
22
nonCacheMeasurement : ( ) => void
23
23
cliProgressBarIncrement : ( ) => void
24
24
originalFilePath : string
25
- originalWidth : number
26
25
sharpOptions ?: Config [ 'sharpOptions' ]
27
26
} & Omit < Manifest [ number ] , 'src' >
28
27
type GetOptimizeResult = ( getOptimizeResultProps : GetOptimizeResultProps ) => Promise < void >
@@ -36,7 +35,6 @@ export const getOptimizeResult: GetOptimizeResult = async ({
36
35
nonCacheMeasurement,
37
36
cliProgressBarIncrement,
38
37
originalFilePath,
39
- originalWidth,
40
38
output,
41
39
width,
42
40
quality,
@@ -75,9 +73,7 @@ export const getOptimizeResult: GetOptimizeResult = async ({
75
73
const imageBuffer = fs . readFileSync ( originalFilePath )
76
74
const image = sharp ( imageBuffer , { sequentialRead : true } )
77
75
78
- const resizeWidth = Math . min ( originalWidth , width )
79
-
80
- image . rotate ( ) . resize ( { width : resizeWidth } )
76
+ image . rotate ( ) . resize ( { width, withoutEnlargement : true } )
81
77
82
78
switch ( extension ) {
83
79
case 'jpeg' :
@@ -137,7 +133,6 @@ export const optimizeImages = async ({ manifestJsonPath, noCache, config }: Opti
137
133
138
134
for ( const item of manifest ) {
139
135
const originalFilePath = path . join ( destDir , item . src )
140
- const originalWidth = ( await sharp ( originalFilePath ) . metadata ( ) ) . width ?? 1280
141
136
142
137
promises . push (
143
138
getOptimizeResult ( {
@@ -149,7 +144,6 @@ export const optimizeImages = async ({ manifestJsonPath, noCache, config }: Opti
149
144
nonCacheMeasurement : ( ) => ( measuredNonCache += 1 ) ,
150
145
cliProgressBarIncrement,
151
146
originalFilePath,
152
- originalWidth,
153
147
sharpOptions : config . sharpOptions ?? { } ,
154
148
...item ,
155
149
} )
0 commit comments