-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
38 lines (32 loc) · 1009 Bytes
/
test.js
File metadata and controls
38 lines (32 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const sevenBin = require('7zip-bin');
const node7z = require('node-7z');
const pathTo7zip = sevenBin.path7za;
const sharp = require('sharp');
function test() {
const myStream = node7z.add('./test.7z', 'D:/BaiduNetdiskDownload/[辰鋒]斗罗玉传 斗罗玉转/16-20', {
recursive: true,
$bin: pathTo7zip
});
myStream.on('error', function (err) {
console.log(err);
// a standard error
// `err.stderr` is a string that can contain extra info about the error
})
}
async function toGif(file) {
await sharp(file, { animated: true })
.toFile('1.gif');
}
toGif('./1.webp');
async function testResize(file, originalWidth, width) {
const cropWidth = originalWidth - width;
const left = cropWidth / 2;
const top = 0;
const metadata = await sharp(file).metadata();
const cropHeight = metadata.height;
await sharp(file)
.extract({left: left, top: top, width: width, height: cropHeight})
.toFile(`test.jpg`);
}
// testResize('./00001.jpg', 1920, 740);
// test();