annotate rasterize.js @ 26:ac9641ecf84f

updated rasterize and ss2thumb to cycle offsets of grab for different anchors removed some bad path stuctures
author tzara <rc-web@kiben.net>
date Mon, 16 Jul 2012 16:51:55 +0100
parents d2eda8be1fca
children ea19684cd1db
rev   line source
rc-web@12 1 var page = require('webpage').create(),
rc-web@12 2 system = require('system'),
rc-web@12 3 address, output, size;
rc-web@12 4
rc-web@26 5 top = system.args[3];
rc-web@26 6
rc-web@26 7 page.clipRect = { top: top, left: 0, width: 1280, height: 800 }
rc-web@12 8
rc-web@12 9 if (system.args.length < 3 || system.args.length > 5) {
rc-web@12 10 console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]');
rc-web@12 11 console.log(' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"');
rc-web@12 12 phantom.exit(1);
rc-web@12 13 } else {
rc-web@12 14 address = system.args[1];
rc-web@12 15 output = system.args[2];
rc-web@26 16
rc-web@26 17
rc-web@12 18 page.viewportSize = { width: 800, height: 800 };
rc-web@26 19 if (system.args.length > 4 && system.args[2].substr(-4) === ".pdf") {
rc-web@26 20 size = system.args[4].split('*');
rc-web@12 21 page.paperSize = size.length === 2 ? { width: size[0], height: size[1], margin: '0px' }
rc-web@12 22 : { format: system.args[3], orientation: 'portrait', margin: '1cm' };
rc-web@12 23 }
rc-web@26 24 if (system.args.length > 5) {
rc-web@26 25 page.zoomFactor = system.args[5];
rc-web@12 26 }
rc-web@12 27 page.open(address, function (status) {
rc-web@12 28 if (status !== 'success') {
rc-web@12 29 console.log('Unable to load the address!');
rc-web@12 30 } else {
rc-web@12 31 window.setTimeout(function () {
rc-web@12 32 page.render(output);
rc-web@12 33 phantom.exit();
rc-web@12 34 }, 200);
rc-web@12 35 }
rc-web@12 36 });
rc-web@12 37 }