本文整理汇总了TypeScript中gm类的典型用法代码示例。如果您正苦于以下问题:TypeScript gm类的具体用法?TypeScript gm怎么用?TypeScript gm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了gm类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: gm
router.post('/image/profile/:id', upload.single('avatar'), userMW.verify, (req, res) => {
if ((req.userId === req.params['id']) && req.file) {
gm(req.file.path).compress("JPEG").toBuffer((err, buf) => {
r.table("users").get(req.params['id']).run(req.conn)
.then((result: any) => {
if (result && result.avatar) {
r.table("files").get(result.avatar).delete().run(req.conn)
.then(() => {
return r.table("files").insert({ file: buf }).run(req.conn)
}).then((result) => {
return r.table("users").get(req.params['id']).update({ avatar: result.generated_keys[0] }).run(req.conn)
})
.then((result) => {
res.end("Upload successful")
})
.error((err) => {
res.status(500).end('Error occured while updating profile photo');
})
} else {
r.table("files").insert({ file: buf }).run(req.conn)
.then((result) => {
return r.table("users").get(req.params['id']).update({ avatar: result.generated_keys[0] }).run(req.conn)
})
.then((result) => {
res.end("Upload successful")
})
.error((err) => {
res.status(500).end('Failed to change profile photo')
})
}
}).error((err) => {
console.log(err)
res.end('err')
})
})
} else if (req.isAdmin && req.file) {
gm(req.file.path).compress("JPEG").toBuffer((err, buf) => {
r.table("files").insert({ file: buf }).run(req.conn)
.then((result) => {
return r.table("users").get(req.params['id']).update({ avatar: result.generated_keys[0] }).run(req.conn)
})
.then((result) => {
res.end("Upload successful")
})
.error((err) => {
res.status(500).end('Failed to change profile photo')
})
})
} else {
res.status(401).end('Unauthorized');
}
});
开发者ID:triniwiz,项目名称:mojichat-api,代码行数:52,代码来源:users.ts
示例2: thumbnail
async function thumbnail(data: Buffer, type: string, resize: number, res: express.Response): Promise<any> {
if (!/^image\/.*$/.test(type)) {
data = fs.readFileSync(__dirname + '/resources/dummy.png');
}
let g = gm(data);
if (resize) {
g = g.resize(resize, resize);
}
g
.compress('jpeg')
.quality(80)
.toBuffer('jpeg', (err, img) => {
if (err !== undefined && err !== null) {
console.error(err);
res.sendStatus(500);
return;
}
res.header('Content-Type', 'image/jpeg');
res.send(img);
});
}
开发者ID:syuilo,项目名称:misskey-core,代码行数:25,代码来源:server.ts
示例3: painter
export function painter(inputStreams: TestStream[], operatorLabel: string, outputStreams: TestStream[], filename: string) {
inputStreams = sanitizeHigherOrderInputStreams(inputStreams, outputStreams);
const maxFrame = getMaxFrame(inputStreams.concat(outputStreams)) || DEFAULT_MAX_FRAME;
let allStreamsHeight = inputStreams.concat(outputStreams)
.map(measureStreamHeight(maxFrame))
.reduce(function (x, y) { return x + y; }, 0);
canvasHeight = allStreamsHeight + OPERATOR_HEIGHT;
let heightSoFar = 0;
let out: GMObject = gm(CANVAS_WIDTH, canvasHeight, '#ffffff');
inputStreams.forEach(function (streamData) {
out = drawObservable(out, maxFrame, heightSoFar, streamData, false);
heightSoFar += measureStreamHeight(maxFrame)(streamData);
});
out = drawOperator(out, operatorLabel, heightSoFar);
heightSoFar += OPERATOR_HEIGHT;
outputStreams.forEach(function (streamData) {
let isSpecial = inputStreams.length > 0 && areEqualStreamData(inputStreams[0], streamData);
out = drawObservable(out, maxFrame, heightSoFar, streamData, isSpecial);
heightSoFar += measureStreamHeight(maxFrame)(streamData);
});
out.write(filename, function (err: Error) {
if (err) {
return console.error(arguments);
}
});
}
开发者ID:DallanQ,项目名称:rxjs,代码行数:27,代码来源:painter.ts
示例4: Promise
return new Promise((resolve, reject) => {
console.log("Attempting to process image")
// let i = path.join(__dirname, "images", "image.png")
// console.log(i)
gm("images/image.png").identify( (err, value) => {
console.log(value)
resolve(value)
})
})
开发者ID:aheinrich,项目名称:websocket-image-server,代码行数:11,代码来源:image.controller.ts
示例5: Promise
const getPictureProperty = (file, fileName) => new Promise((resolve, reject) => {
gm(file, fileName).size((getSizeErr: any, whsize: any) => {
if (getSizeErr !== undefined && getSizeErr !== null) {
console.error(getSizeErr);
return resolve();
}
return resolve({
width: whsize.width,
height: whsize.height
});
});
});
开发者ID:Tosuke,项目名称:Misskey-API,代码行数:12,代码来源:add-file-to-album.ts
示例6: gm
return mio.promiseUnsafe<mio.IBlob>(callback => gm(image as any).sharpen(5, 1.4).normalize().toBuffer(callback));
开发者ID:murraypaul,项目名称:mangarack,代码行数:1,代码来源:imageService.ts
注:本文中的gm类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论