API
General
Ichabod runs as a single-threaded process handling one request at a time. In order to support parallel processing, consider running multiple copies behind a proxy.
Command line options
The following command line options control various aspects of the rendering engine:
-
--portThe port to listen to for requests.
-
--verbosityDebug output level. Specifying levels greater than zero will print out processing details to the console.
-
--engine-verbosityDebug output level for rendering engine (qt webkit).
-
--convert-verbosityDebug output level for image rasterization.
-
--slow-response-msNumber of milliseconds before considering a response to be slow. This could happen for several reasons (e.g., waiting on an external asset request). Once a slow response is detected, debug output is turned all the way up to aid in debugging.
-
--quantizeQuantization method to use when downsampling images for animated gif output. By default, this is
MEDIANCUT, which is a high quality method for reducing the number of colors in an image. Other options are:THRESHOLDFast and ugly color mappingDIFFUSEAlso fast, less uglyORDEREDVery fast, very uglyMEDIANCUT- Acceptable speed, high qualityMEDIANCUT_FLOYD- A modified version ofMEDIANCUTusing a different dithering algorithm.
-
--versionOutput the version and quit.
-
--statsd-hostOptional statsd host.
-
--statsd-portOptional statsd port.
-
--statsd-nsOptional statsd namespace when sending activity.
JSON Request
Ichabod only accepts requests formatted as a JSON object. Here are the required and optional fields which are accepted:
formatDefault ispng. Also acceptsgif.htmlHTML source code to render and rasterize. Also seeurl.urlOptional. If nohtmlis specified, the HTML from this URL will be used.jsJavascript to execute after HTML is loaded and ready.rasterizerOptional. Name of the rendering object which can be controlled with javascript. Default isichabod.outputPath and filename to write the final image to. This must be accessible to the ichabod process.transparentOptional. Boolean value which can enable transparent background. Default is 1. Typically set to 0 for animated output.widthWidth of the virtual screen used to render the HTML.heightOptional. Height of the virtual screen used to render the HTML. Default is -1, which will dynamically grow the height according to the HTML being rendered..crop_xOptional. X coordinate of final crop rectangle. Cropping takes place as the final step of rasterization.crop_yOptional. Y coordinate of final crop rectangle. Cropping takes place as the final step of rasterization.crop_wOptional. Width of final crop rectangle. Cropping takes place as the final step of rasterization.crop_hOptional. Height of final crop rectangle. Cropping takes place as the final step of rasterization.smart_widthOptional. Dynamically grow the width according to HTML being rendered. Default is 1.css- Optional. Additional CSS to apply after the HTML is loaded.selectorOptional. CSS selector to rasterize instead of the entire HTML body.load_timeoutOptional. Maximum time allowed for a document to load before giving up. Typically used withurl.enable_statsdOptional. Send activity to statsd.statsd_nsOptional. Namespace to use when communicating with statsd.
JSON Response
After processing a request, a response is returned to the client as a JSON string. The following fields are returned:
conversionBoolean indicating whether a successful rasterization took placeconvert_elapsedElapsed time for image rasterizationerrorsList of human readable errors within ichabod and from the javascript console.pathOutput path of the rendered image. Will correspond to the requestoutputfield when successful.resultReturn value from the javascript. Can be null.run_elapsedElapsed time for everything: handling the request, rendering the HTML and rastering the image.warningsList of human readable warnings, including javascript console output.
Runtime object
After ichabod loads the HTML (either specified directly in the request
object, or loaded from a remote URL) then any javascript sent in the
request is executed. In order to trigger rasterization, an internal
javascript obejct (by default called ichabod) can be used. This
object has several useful methods:
setTransparentTakes a boolean argument indicating whether or not background transparency should be used when rendering.setQualitySet the quality of the render as an integer from 1 to 100. By default, this is 50 which is a good tradeoff between speed and quality.setScreenSet the dimensions of the virtual screen for rasterization. Specify x, y, width and height as integers.setFormatSet the format of the rasterization output. Usepngorgif.setLoopingTakes a boolean to enable or disable looping for animated output.snapshotPageRasterizes the entire HTML into memory. This method can be called multiple times. When writing animated files, you can also specify a delay (in milliseconds). When writing animated output, all rasterized images are compiled into a gif. When writing a static image as output, only the last rasterized image is used.snapshotElementsRasterizes one or more CSS identifiers within the HTML. Otherwise, similar tosnapshotPage.saveToOutputSaves the rasterized image(s) to disk. Once this method is called, no more rasterization can take place.setQuantizeMethodChanges the quanitization method for downsampling images when writing animated gifs.setSelectorSets the full CSS path to an element, which limits the rasterization to that area of the page.setCssSpecifies additional CSS which is applied immediately to the page.setCropRectSpecifies the absolute x, y, width and height of a cropping rectangle. This crop takes place as the last step of rasterization.setSmartWidthTakes a boolean argument to enable or disable using smart width calculation before rasterizing.