File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,12 +9,17 @@ import convertToUnixPath from 'slash';
99import { assertUint8Array } from 'uint8array-extras' ;
1010import { isBrowser } from 'environment' ;
1111import ow from 'ow' ;
12+ import { imageDimensionsFromData } from 'image-dimensions' ;
1213
1314const handleFile = async ( sourcePath , { destination, plugins = [ ] } ) => {
1415 ow ( plugins , ow . optional . array . message ( 'The `plugins` option should be an `Array`' ) ) ;
1516
1617 let data = await fsPromises . readFile ( sourcePath ) ;
17- data = await ( plugins . length > 0 ? pPipe ( ...plugins ) ( data ) : data ) ;
18+
19+ const dimensions = imageDimensionsFromData ( data ) ;
20+ if ( dimensions === undefined || ( dimensions . width !== 0 && dimensions . height !== 0 ) ) {
21+ data = await ( plugins . length > 0 ? pPipe ( ...plugins ) ( data ) : data ) ;
22+ }
1823
1924 const { ext} = await fileTypeFromBuffer ( data ) ?? { ext : path . extname ( sourcePath ) } ;
2025 let destinationPath = destination ? path . join ( destination , path . basename ( sourcePath ) ) : undefined ;
Original file line number Diff line number Diff line change 3232 "environment" : " ^1.0.0" ,
3333 "file-type" : " ^19.0.0" ,
3434 "globby" : " ^14.0.1" ,
35+ "image-dimensions" : " ^2.3.0" ,
3536 "junk" : " ^4.0.1" ,
3637 "ow" : " ^2.0.0" ,
3738 "p-pipe" : " ^4.0.0" ,
4243 "ava" : " ^6.1.2" ,
4344 "del" : " ^7.1.0" ,
4445 "imagemin-jpegtran" : " ^7.0.0" ,
45- "imagemin-svgo" : " ^10 .0.1" ,
46+ "imagemin-svgo" : " ^11 .0.1" ,
4647 "imagemin-webp" : " ^8.0.0" ,
4748 "tempy" : " ^3.1.0" ,
4849 "xo" : " ^0.58.0"
Original file line number Diff line number Diff line change 22
33> Minify images seamlessly
44
5- <br >
6-
7- ---
8-
9- <div align =" center " >
10- <p>
11- <p>
12- <sup>
13- <a href="https://github.com/sponsors/sindresorhus">Sindre Sorhus' open source work is supported by the community</a>
14- </sup>
15- </p>
16- <sup>Special thanks to:</sup>
17- <br>
18- <br>
19- <a href="https://standardresume.co/tech">
20- <img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="180">
21- </a>
22- <br>
23- <br>
24- <a href="https://strapi.io/?ref=sindresorhus">
25- <div>
26- <img src="https://sindresorhus.com/assets/thanks/strapi-logo-white-bg.png" width="200" alt="Strapi">
27- </div>
28- <b>Strapi is the leading open-source headless CMS.</b>
29- <div>
30- <sup>It’s 100% JavaScript, fully customizable, and developer-first.</sup>
31- </div>
32- </a>
33- </p>
34- </div >
35-
36- ---
37-
38- <br >
39-
405## Install
416
427``` sh
You can’t perform that action at this time.
0 commit comments