@divriots/jampack 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compress.js +17 -2
- package/dist/optimize.js +1 -1
- package/dist/options.js +1 -1
- package/package.json +1 -1
package/dist/compress.js
CHANGED
|
@@ -89,7 +89,18 @@ export const compressImage = async (data, resize) => {
|
|
|
89
89
|
const meta = await sharpFile.metadata();
|
|
90
90
|
switch (meta.format) {
|
|
91
91
|
case 'svg':
|
|
92
|
-
const newData = svgo(data, {
|
|
92
|
+
const newData = svgo(data, {
|
|
93
|
+
multipass: true,
|
|
94
|
+
plugins: [{
|
|
95
|
+
name: "preset-default",
|
|
96
|
+
params: {
|
|
97
|
+
overrides: {
|
|
98
|
+
removeViewBox: false,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
});
|
|
93
104
|
if (newData.error || newData.modernError) {
|
|
94
105
|
console.log(`Error processing svg ${data}`);
|
|
95
106
|
return undefined;
|
|
@@ -100,7 +111,11 @@ export const compressImage = async (data, resize) => {
|
|
|
100
111
|
case 'jpeg':
|
|
101
112
|
case 'webp':
|
|
102
113
|
//case 'gif':
|
|
103
|
-
|
|
114
|
+
let sf = sharpFile;
|
|
115
|
+
if (resize.width && resize.height) {
|
|
116
|
+
sf = sf.resize({ ...resize, fit: 'fill', withoutEnlargement: true });
|
|
117
|
+
}
|
|
118
|
+
return await sf.toBuffer();
|
|
104
119
|
}
|
|
105
120
|
return undefined;
|
|
106
121
|
};
|
package/dist/optimize.js
CHANGED
|
@@ -141,7 +141,7 @@ async function processImage(file, $, imgElement) {
|
|
|
141
141
|
originalSize: originalData.length,
|
|
142
142
|
compressedSize: originalData.length
|
|
143
143
|
};
|
|
144
|
-
const newImage = await compressImage(originalData, {
|
|
144
|
+
const newImage = await compressImage(originalData, {});
|
|
145
145
|
if (newImage && newImage.length < originalData.length) {
|
|
146
146
|
if (!globalState.args.nowrite) {
|
|
147
147
|
fs.writeFile(absoluteImgPath, newImage);
|
package/dist/options.js
CHANGED