當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript sharp.queue類代碼示例

本文整理匯總了TypeScript中sharp.queue的典型用法代碼示例。如果您正苦於以下問題:TypeScript queue類的具體用法?TypeScript queue怎麽用?TypeScript queue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了queue類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: sharp

        // output.jpg is a 300 pixels wide and 200 pixels high image
        // containing a scaled and cropped version of input.jpg
    });

let transformer = sharp()
    .resize(300)
    .on('info', (info: sharp.OutputInfo) => {
        console.log('Image height is ' + info.height);
    });
readableStream.pipe(transformer).pipe(writableStream);

console.log(sharp.format);
console.log(sharp.versions);

sharp.queue.on('change', (queueLength: number) => {
    console.log('Queue contains ' + queueLength + ' task(s)');
});

let pipeline: sharp.SharpInstance = sharp().rotate();
pipeline.clone().resize(800, 600).pipe(writableStream);
pipeline.clone().extract({ left: 20, top: 20, width: 100, height: 100 }).pipe(writableStream);
readableStream.pipe(pipeline);
// firstWritableStream receives auto-rotated, resized readableStream
// secondWritableStream receives auto-rotated, extracted region of readableStream

const image: sharp.SharpInstance = sharp(input);
image
    .metadata()
    .then<Buffer|undefined>((metadata: sharp.Metadata) => {
        if (metadata.width) {
            return image
開發者ID:minodisk,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:sharp-tests.ts

示例2: sharp

        // output.jpg is a 300 pixels wide and 200 pixels high image
        // containing a scaled and cropped version of input.jpg
    });

let transformer = sharp()
    .resize(300)
    .on('info', (info: sharp.OutputInfo) => {
        console.log('Image height is ' + info.height);
    });
readableStream.pipe(transformer).pipe(writableStream);

console.log(sharp.format);
console.log(sharp.versions);

sharp.queue.on('change', (queueLength: number) => {
    console.log(`Queue contains ${queueLength} task(s)`);
});

let pipeline: sharp.SharpInstance = sharp().rotate();
pipeline.clone().resize(800, 600).pipe(writableStream);
pipeline.clone().extract({ left: 20, top: 20, width: 100, height: 100 }).pipe(writableStream);
readableStream.pipe(pipeline);
// firstWritableStream receives auto-rotated, resized readableStream
// secondWritableStream receives auto-rotated, extracted region of readableStream

const image: sharp.SharpInstance = sharp(input);
image
    .metadata()
    .then<Buffer|undefined>((metadata: sharp.Metadata) => {
        if (metadata.width) {
            return image
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:sharp-tests.ts


注:本文中的sharp.queue類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。