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


TypeScript jimp.read函數代碼示例

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


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

示例1: getDimensions

/**
 * Gets dimension of first image in folder.
 * assumes that all images in folder are the same size
 * @param dir
 * @param callback
 */
function getDimensions(dir: string, callback: Function): void {
  let file = fs.readdirSync(dir)[0];

  jimp.read(dir + file, function (err: any, img: any) {
    if (err) throw err;
    callback(null, {width: img.bitmap.width, height: img.bitmap.height});
  });
}
開發者ID:,項目名稱:,代碼行數:14,代碼來源:

示例2: getCaptchaRegion

  async getCaptchaRegion(clientOffset:{top:number,left:number}): Promise<any> {
    const img = await screenshot();
    const image = await Jimp.read(img);
    image.crop(clip.x+clientOffset.left, clip.y + clientOffset.top, clip.w, clip.h);
    return new Promise((resolve, reject)=>{
      image.getBase64(Jimp.MIME_PNG, (e, d) => {
        resolve("" + d);
      });
    })

  }
開發者ID:a727891,項目名稱:bb,代碼行數:11,代碼來源:CaptchaResponder.ts

示例3: manipulateImage

export async function manipulateImage({
  img,
  output,
  actions,
  verbose,
  loadFont: font
}: ICliOptions) {
  log(` 📷  Loading source image: ${img} ...`, verbose);

  const image = await Jimp.read(img);

  await processImage(image, font, actions, output, verbose);
}
開發者ID:oliver-moran,項目名稱:jimp,代碼行數:13,代碼來源:process-image.ts

示例4: getEventDocs

 public getEventDocs(req: express.Request, res: express.Response): void {
     const input: EventDocInputModel = req.body;
     if (input.organizerClubUrl) {
         Jimp.read(input.organizerClubUrl).then((imageData: Jimp) => {
             imageData.getBuffer(Jimp.MIME_PNG, ((error, jpegImage) => {
                 if (error) {
                     this.handleResponse(req, res,
                         'Das Logo von ' + input.organizerTeamName + ' kann nicht verwendet werden.', null);
                 } else {
                     this._floorballzTournamentDocumentService.getEventDocs(input, jpegImage).pipe(res);
                 }
             }));
         }).catch(() => {
             this.handleResponse(req, res,
                 'Das Logo von ' + input.organizerTeamName + ' kann nicht herunter geladen werden.', null);
         });
     } else {
         this._floorballzTournamentDocumentService.getEventDocs(input, undefined).pipe(res);
     }
 }
開發者ID:chiefmaster7,項目名稱:helperZone,代碼行數:20,代碼來源:SwissUnihockeyApiProxyController.ts

示例5: reject

  const future = new Promise<string>(async (resolve, reject) => {
    await Jimp.read(await file.toBuffer(), (err, image) => {
      if (err) {
        return reject(err)
      }

      const qrCodeImageArray = new Uint8ClampedArray(image.bitmap.data.buffer)

      const qrCodeResult = jsQR(
        qrCodeImageArray,
        image.bitmap.width,
        image.bitmap.height,
      )

      if (qrCodeResult) {
        return resolve(qrCodeResult.data)
      } else {
        return reject(new Error('WXGetQRCode() qrCode decode fail'))
      }
    })
  })
開發者ID:miggame,項目名稱:wechaty,代碼行數:21,代碼來源:file-box-to-qrcode.ts

示例6: function

    function(file: string, asyncCallback: Function) {
      jimp.read(dir + file, function (err: any, img: any) {
        if (err) throw err;
        images.push(img.bitmap.data);
        process.stdout.write('.');
        // img.scan(0, 0, img.bitmap.width, img.bitmap.height, function (x: number, y: number, idx: number) {
        //   // x, y is the position of this pixel on the image
        //   // idx is the position start position of this rgba tuple in the bitmap Buffer
        //   // this is the image
        //
        //   imgPixels.push(this.bitmap.data[idx]);     // Red
        //   imgPixels.push(this.bitmap.data[idx + 1]); // Green
        //   imgPixels.push(this.bitmap.data[idx + 2]); // Blue
        //
        //   // rgba values run from 0 - 255
        //   // e.g. this.bitmap.data[idx] = 0; // removes red from this pixel
        // });

        // images[index] = imgPixels;
        asyncCallback();
      });
    },
開發者ID:,項目名稱:,代碼行數:22,代碼來源:

示例7: require

import * as Jimp from "jimp";
const _Jimp = require("jimp");

// open a file called "lenna.png"
Jimp.read("lenna.png", (err, lenna) => {
    if (err) throw err;
    
    lenna.resize(256, 256)            // resize
         .quality(60)                 // set JPEG quality
         .greyscale()                 // set greyscale
         .write("lena-small-bw.jpg"); // save
});


// Using promises
Jimp.read("lenna.png")
    .then(lenna => {
        lenna.resize(256, 256)            // resize
            .quality(60)                 // set JPEG quality
            .greyscale()                 // set greyscale
            .write("lena-small-bw.jpg"); // save
    })
    .catch(err => {
        console.error(err);
    });


// Basic usage
Jimp.read("./path/to/image.jpg", (err, image) => {
    // do stuff with the image (if no exception)
});
開發者ID:typed-contrib,項目名稱:jimp,代碼行數:31,代碼來源:index.ts


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