cronshot-imagemagick 是 cronshot 中间件,通过 gm 来操作和保存 ImageMagick 处理的图片。
安装
npm install cronshot-imagemagick
示例
var cronshot = require('cronshot'), middleware = { 'imagemagick': require('cronshot-imagemagick') }; // Image Magick Example // -------------------- // Takes a screenshot of sports.yahoo.com, // and converts the screenshot to be a transparent image using Image Magick // Image Magick example cronshot.startCapturing({ // The webpage URL that you would like to take a screenshot of 'url': 'http://sports.yahoo.com', // The local path where you would like to save the image 'path': __dirname, // Only takes one screenshot 'cronPattern': false, // What middleware functions to use each time a screenshot is taken 'saveMiddleware': [{ // Function that does all the Image Magick stuff 'middleware': middleware.imagemagick, 'options': { 'gmCommands': [{ 'method': 'trim', 'args': [] }, { 'method': 'transparent', 'args': ['#FFFFFF'] }] } }] }, function(err) { // optional callback function once all screenshots have been taken });