Skip to content

Commit 524a67c

Browse files
committed
Meta tweaks
1 parent 51f8efd commit 524a67c

3 files changed

Lines changed: 8 additions & 37 deletions

File tree

index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ import convertToUnixPath from 'slash';
99
import {assertUint8Array} from 'uint8array-extras';
1010
import {isBrowser} from 'environment';
1111
import ow from 'ow';
12+
import {imageDimensionsFromData} from 'image-dimensions';
1213

1314
const 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;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
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",
@@ -42,7 +43,7 @@
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"

readme.md

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,6 @@
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

0 commit comments

Comments
 (0)