当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Node.js GM solarize()用法及代码示例


solarize()函数是GraphicsMagick库中的内置函数,用于否定阈值级别以上的所有像素。成功时该函数返回真实值。

用法:

solarize(thresholdLevel)

参数:此函数接受单个参数thresholdevel,该参数用于在0到100之间指定阈值级别。



返回值:此函数返回GraphicsMagick对象。

范例1:

// Include gm library 
var gm = require('gm'); 
  
// Import the image 
gm('1.png') 
  
// Invoke solarize function 
.solarize(12) 
  
// Process and Write the image 
.write("solarize1.png", function (err) { 
  if (!err) console.log('done'); 
});

输出:

范例2:

// Include gm library 
var 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 solarize function 
.solarize(3) 
  
// Process and Write the image 
.write("solarize2.png", function (err) { 
  if (!err) console.log('done'); 
});

输出:

参考:




相关用法


注:本文由纯净天空筛选整理自sarthak_ishu11大神的英文原创作品 Nodejs | GM solarize() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。