當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Node.js GM motionBlur()用法及代碼示例

motionBlur() 函數是 GraphicsMagick 庫中的內置函數,用於使用具有可配置半徑、西格瑪和角度的高斯卷積核來應用運動模糊效果。該函數返回成功的真實值。

句法:

motionBlur(radius, sigma, angle)

參數:該函數接受three上麵提到的參數和下麵說明的參數:

  • radius:該參數用於指定半徑的值。
  • sigma:該參數用於指定西格瑪的值。
  • angle:該參數用於指定以弧度為單位的角度值。

返回值:該函數返回GraphicsMagick對象。

示例1:

Javascript


// Include gm library
const gm = require('gm');
// Import the image
gm('1.png')
// Invoke borderColor() function
// and set border color to green
.borderColor('Green')
// Invoke resize function
.border(10,30)
// Invoke motionblur function
.motionBlur(10,30,30)
// Process and Write the image
.write("motionblur1.png", function (err) {
    if (!err) console.log('done');
});

輸出:

輸出1

示例2:

Javascript


// Include gm library
const gm = require('gm');
// Import the image
gm(600,300,'white')
// Set the color for the stroke
.stroke("green",3)
// Set the font
.font("Helvetica.ttf",60)
// Call to drawText Function
.drawText(100, 280, "GeeksforGeeks!")
// Invoke borderColor() function
// and set border color to green
.borderColor("Green")
// Invoke border function
.border(62,32)
// Invoke motionBlur() function
.motionBlur(10,10,10)
// Process and write the image
.write("motionblur2.png", function (err) {
    if (!err) console.log('done');
});

輸出:

參考:



相關用法


注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 Node.js GM motionBlur() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。