Last active
August 29, 2015 14:26
-
-
Save simong/5fe2d5584e9f561e9ea4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fabric = require('fabric').fabric; | |
var fs = require('fs'); | |
// A set of images that will be added on the canvas | |
var urls = [ | |
'https://processr-test.s3.amazonaws.com/uploads/309/1294/1038x.jpeg?AWSAccessKeyId=AKIAJFLYD6BOWFRPGKTQ&Expires=1753582685&Signature=zBtU4LRqYud%2Fu9XTwC%2FGNrZRFK0%3D', | |
'https://processr-test.s3.amazonaws.com/uploads/307/1290/1038x.jpeg?AWSAccessKeyId=AKIAJFLYD6BOWFRPGKTQ&Expires=1753582663&Signature=jbEh5fyt0sd3mFXfi6eu66YdTvA%3D', | |
'https://processr-test.s3.amazonaws.com/uploads/308/1292/1038x.jpeg?AWSAccessKeyId=AKIAJFLYD6BOWFRPGKTQ&Expires=1753582666&Signature=wppCeraGe9%2BS7Iykot%2F5GYhLSAY%3D', | |
'https://processr-test.s3.amazonaws.com/uploads/310/1296/1038x.jpeg?AWSAccessKeyId=AKIAJFLYD6BOWFRPGKTQ&Expires=1753582686&Signature=D%2BTU0opwt%2B7QJS4CF%2BUuGq7GxKI%3D', | |
'https://processr-test.s3.amazonaws.com/uploads/313/1302/1038x.jpeg?AWSAccessKeyId=AKIAJFLYD6BOWFRPGKTQ&Expires=1753582674&Signature=gyN25ZnEzuNKIXArLsBwtPwWris%3D', | |
'https://processr-test.s3.amazonaws.com/uploads/311/1298/1038x.jpeg?AWSAccessKeyId=AKIAJFLYD6BOWFRPGKTQ&Expires=1753582670&Signature=Z2Zd0k6fy5lRxGV3WzZt4YiRTcM%3D', | |
'https://processr-test.s3.amazonaws.com/uploads/312/1300/1038x.jpeg?AWSAccessKeyId=AKIAJFLYD6BOWFRPGKTQ&Expires=1753582715&Signature=bhYaQZ3YUneeUxS0cYttPfwZn%2FE%3D' | |
]; | |
var createCanvas = function() { | |
console.log('Creating canvas'); | |
// Get a simple canvas | |
var canvas = fabric.createCanvasForNode(1000, 1000); | |
// Add each image to the canvas | |
urls.forEach(function(url) { | |
fabric.Image.fromURL(url, function(oImg) { | |
canvas.add(oImg); | |
}); | |
}); | |
}; | |
// Create a new canvas every 10 seconds | |
setTimeout(createCanvas, 10000); | |
setTimeout(createCanvas, 20000); | |
setTimeout(createCanvas, 30000); | |
setTimeout(createCanvas, 40000); | |
setTimeout(createCanvas, 50000); | |
setTimeout(createCanvas, 60000); | |
// Keep feeding stuff into Node's queue so the process doesn't close once all the screenshots have | |
// been generated. This is useful to take heapdumps | |
setInterval(function() { | |
console.log('Ping') | |
// Garbage collect when ran with the --expose-gc flag | |
if (global.gc) { | |
global.gc(); | |
} | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment