最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

nodejs處理圖片的中間件node-images詳解

 更新時(shí)間:2017年05月08日 11:46:47   作者:銀狐被占用  
這篇文章主要介紹了nodejs處理圖片的中間件node-images詳解,非常具有實(shí)用價(jià)值,需要的朋友可以參考下

Cross-platform image decoder(png/jpeg/gif) and encoder(png/jpeg) for Node.js

node.js輕量級(jí)跨平臺(tái)圖像編解碼庫(kù)

var images = require("images");

images("input.jpg")           //Load image from file 
                    //加載圖像文件
  .size(400)             //Geometric scaling the image to 400 pixels width
                    //等比縮放圖像到400像素寬
  .draw(images("logo.png"), 10, 10)  //Drawn logo at coordinates (10,10)
                    //在(10,10)處繪制Logo
  .save("output.jpg", {        //Save the image to a file,whih quality 50
    quality : 50          //保存圖片到文件,圖片質(zhì)量為50
  });

Features 功能特性

  1. Lightweight:no need to install any image processing library.
  2. 輕量級(jí):無(wú)需安裝任何圖像處理庫(kù)。
  3. Cross-platform: Released a compiled .node file on windows, just download and start.
  4. 跨平臺(tái):Windows下發(fā)布了編譯好的.node文件,下載就能用。
  5. Easy-to-use: Provide jQuery-like chaining API.Simple and reliable!
  6. 方便用:jQuery風(fēng)格的API,簡(jiǎn)單可依賴。

Installation 安裝

$ npm install images

API 接口

node-images provide jQuery-like Chaining API,You can start the chain like this:

node-images 提供了類似jQuery的鏈?zhǔn)秸{(diào)用API,您可以這樣開始:

/* Load and decode image from file */
/* 從指定文件加載并解碼圖像 */
images(file)

/* Create a new transparent image */
/* 創(chuàng)建一個(gè)指定寬高的透明圖像 */
images(width, height)

/* Load and decode image from a buffer */
/* 從Buffer數(shù)據(jù)中解碼圖像 */
images(buffer[, start[, end]])

/* Copy from another image */
/* 從另一個(gè)圖像中復(fù)制區(qū)域來(lái)創(chuàng)建圖像 */
images(image[, x, y, width, height])

images(file)

Load and decode image from file從指定文件加載并解碼圖像

images(width, height)

Create a new transparent image創(chuàng)建一個(gè)指定寬高的透明圖像

images(buffer[, start[, end]])

Load and decode image from a buffer從Buffer數(shù)據(jù)中解碼圖像

images(image[, x, y, width, height])

Copy from another image從另一個(gè)圖像中復(fù)制區(qū)域來(lái)創(chuàng)建圖像

.fill(red, green, blue[, alpha])

eg:images(200, 100).fill(0xff, 0x00, 0x00, 0.5) Fill image with color以指定顏色填充圖像

.draw(image, x, y)

Draw image on the current image position( x , y )在當(dāng)前圖像( x , y )上繪制 image 圖像

.encode(type[, config])

eg:images("input.png").encode("jpg", {operation:50}) Encode image to buffer, config is image setting.

以指定格式編碼當(dāng)前圖像到Buffer,config為圖片設(shè)置,目前支持設(shè)置JPG圖像質(zhì)量

Return buffer

返回填充好的Buffer

Note:The operation will cut off the chain

注意:該操作將會(huì)切斷調(diào)用鏈

See:.save(file[, type[, config]]) 參考:.save(file[, type[, config]])

.save(file[, type[, config]])

eg:images("input.png").encode("output.jpg", {operation:50}) Encoding and save the current image to a file, if the type is not specified, type well be automatically determined according to the file, config is image setting. eg: { operation:50 }
編碼并保存當(dāng)前圖像到 file ,如果type未指定,則根據(jù) file 自動(dòng)判斷文件類型,config為圖片設(shè)置,目前支持設(shè)置JPG圖像質(zhì)量

.size([width[, height]])

Get size of the image or set the size of the image,if the height is not specified, then scaling based on the current width and height獲取或者設(shè)置圖像寬高,如果height未指定,則根據(jù)當(dāng)前寬高等比縮放

.resize(width[, height])

Set the size of the image,if the height is not specified, then scaling based on the current width and height

設(shè)置圖像寬高,如果height未指定,則根據(jù)當(dāng)前寬高等比縮放, 默認(rèn)采用 bicubic 算法。

.width([width])

Get width for the image or set width of the image獲取或設(shè)置圖像寬度

.height([height])

Get height for the image or set height of the image獲取或設(shè)置圖像高度

images.setLimit(width, height)

Set the limit size of each image  設(shè)置庫(kù)處理圖片的大小限制,設(shè)置后對(duì)所有新的操作生效(如果超限則拋出異常)

images.setGCThreshold(value)

Set the garbage collection threshold   設(shè)置圖像處理庫(kù)自動(dòng)gc的閾值(當(dāng)新增內(nèi)存使用超過該閾值時(shí),執(zhí)行垃圾回收)

images.getUsedMemory()

Get used memory (in bytes)得到圖像處理庫(kù)占用的內(nèi)存大小(單位為字節(jié))

images.gc()

Forced call garbage collection 強(qiáng)制調(diào)用V8的垃圾回收機(jī)制

https://github.com/zhangyuanwei/node-images

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 使用Express+Node.js對(duì)mysql進(jìn)行增改查操作?

    使用Express+Node.js對(duì)mysql進(jìn)行增改查操作?

    這篇文章主要介紹了使用Express+Node.js對(duì)mysql進(jìn)行增改查操作,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下
    2022-08-08
  • nodejs 十六進(jìn)制字符串型數(shù)據(jù)與btye型數(shù)據(jù)相互轉(zhuǎn)換

    nodejs 十六進(jìn)制字符串型數(shù)據(jù)與btye型數(shù)據(jù)相互轉(zhuǎn)換

    這篇文章主要介紹了nodejs 十六進(jìn)制字符串型數(shù)據(jù)與btye型數(shù)據(jù)相互轉(zhuǎn)換,需要的朋友可以參考下
    2018-07-07
  • Node.js添加API限流與日志優(yōu)化詳解

    Node.js添加API限流與日志優(yōu)化詳解

    這篇文章主要介紹了Node.js添加API限流與日志優(yōu)化的相關(guān)資料,以增強(qiáng)API的穩(wěn)定性和可維護(hù)性,API限流功能可以防止惡意請(qǐng)求和DDoS攻擊,優(yōu)化后的日志記錄系統(tǒng)則可以幫助我們更好地跟蹤和調(diào)試應(yīng)用,快速定位問題,需要的朋友可以參考下
    2024-11-11
  • linux 后臺(tái)運(yùn)行node服務(wù)指令方法

    linux 后臺(tái)運(yùn)行node服務(wù)指令方法

    今天小編就為大家分享一篇linux 后臺(tái)運(yùn)行node服務(wù)指令方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧
    2018-05-05
  • 基于Node.js的WebSocket通信實(shí)現(xiàn)

    基于Node.js的WebSocket通信實(shí)現(xiàn)

    這篇文章主要介紹了基于Node.js的WebSocket通信實(shí)現(xiàn),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧
    2017-03-03
  • node.js 利用流實(shí)現(xiàn)讀寫同步,邊讀邊寫的方法

    node.js 利用流實(shí)現(xiàn)讀寫同步,邊讀邊寫的方法

    下面小編就為大家?guī)?lái)一篇node.js 利用流實(shí)現(xiàn)讀寫同步,邊讀邊寫的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧
    2017-09-09
  • node.js多個(gè)異步過程中判斷執(zhí)行是否完成的解決方案

    node.js多個(gè)異步過程中判斷執(zhí)行是否完成的解決方案

    這篇文章主要給大家介紹了關(guān)于node.js多個(gè)異步過程中判斷執(zhí)行是否完成的幾種解決方案,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起看看吧。
    2017-12-12
  • NodeJs Express框架實(shí)現(xiàn)服務(wù)器接口詳解

    NodeJs Express框架實(shí)現(xiàn)服務(wù)器接口詳解

    最近學(xué)習(xí)了基于前后端分離的開發(fā)模式,我前端使用Vue框架,后端使用nodejs開發(fā)API接口,下面這篇文章主要給大家介紹了關(guān)于nodejs使用Express框架寫后端接口的相關(guān)資料,需要的朋友可以參考下
    2022-08-08
  • json對(duì)象及數(shù)組鍵值的深度大小寫轉(zhuǎn)換問題詳解

    json對(duì)象及數(shù)組鍵值的深度大小寫轉(zhuǎn)換問題詳解

    這篇文章主要給大家介紹了關(guān)于json對(duì)象及數(shù)組鍵值的深度大小寫轉(zhuǎn)換問題的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-03-03
  • 14款NodeJS Web框架推薦

    14款NodeJS Web框架推薦

    這篇文章主要介紹了14款NodeJS Web框架推薦,其中大多數(shù)框架都是基于node.js的Express實(shí)現(xiàn),需要的朋友可以參考下
    2014-07-07

最新評(píng)論

昌宁县| 鄂托克旗| 开封县| 木兰县| 和政县| 阳春市| 土默特左旗| 肥乡县| 辽宁省| 临桂县| 慈利县| 岑溪市| 玉林市| 自治县| 康保县| 东乡| 四子王旗| 余姚市| 平定县| 隆尧县| 石屏县| 岳阳市| 佳木斯市| 南昌市| 邮箱| 佛冈县| 池州市| 望江县| 丰原市| 张掖市| 焉耆| 正宁县| 揭西县| 图片| 岳西县| 吉隆县| 张掖市| 枣强县| 太仆寺旗| 平阴县| 吴忠市|