当前位置: 首页>>代码示例>>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;未经允许,请勿转载。