Download png image outside of the webside

Hi,

I am generating graph by embed.file_html and I am trying to get plot image in png. I know it is possible by clicking save button from tools but I want to make it using just scripts in python. Do you have any idea how can I make it?

This is not currently possible, unfortunately. There is a long standing open issue you can follow for progress and discussion:

  Headless static (svg, png) image generation · Issue #538 · bokeh/bokeh · GitHub

There is a potentially promising avenue involving the headless Chrome project, but it would be Linux-only to start (since headless Chrome is currently Linux-only). This is unfortunately very difficult problem, for lots of different reasons. If programmatic static image generation is your top requirement for you, my best suggestion currently is to look at other libraries.

Thanks,

Bryan

···

On Sep 7, 2016, at 9:03 AM, Wojciech Askuntowicz <[email protected]> wrote:

Hi,

I am generating graph by embed.file_html and I am trying to get plot image in png. I know it is possible by clicking save button from tools but I want to make it using just scripts in python. Do you have any idea how can I make it?

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/80339734-455b-4969-9ea1-7e7329b25f3f%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

I was able to programmatically generate PNGs from Bokeh HTML files using phantom.js (http://phantomjs.org/) and the attached JS code that I found somewhere (probably on stackoverflow). I have python script that generates the html file using Bokeh then a separate python script that makes a subprocess call like the following:

phantom.js.exe report.js file:///D:/temp/input.html D:/temp/output.png

The three slashes seems weird to me but I have a comment in my code that "PhantomJS needs the full URL file path and/or maybe that is just a windows thing.

Charles

If the report.js file doesn’t attach, here are the contents:

“use strict”;

var page = require(‘webpage’).create(),

system = require(‘system’),

address, output, size;

address = system.args[1];

output = system.args[2];

var width = 900

var height = 400

page.viewportSize = { width: width, height: height };

page.clipRect = { top: 30, left: 10, width: width-30, height: height-35 };

page.open(address, function (status) {

if (status !== ‘success’) {

console.log(‘Unable to load the address!’);

phantom.exit(1);

} else {

window.setTimeout(function () {

page.render(output);

phantom.exit();

}, 1000);

}

});

report.js (619 Bytes)

···

On Wed, Sep 7, 2016 at 7:57 AM, Bryan Van de Ven [email protected] wrote:

This is not currently possible, unfortunately. There is a long standing open issue you can follow for progress and discussion:

    [https://github.com/bokeh/bokeh/issues/538](https://github.com/bokeh/bokeh/issues/538)

There is a potentially promising avenue involving the headless Chrome project, but it would be Linux-only to start (since headless Chrome is currently Linux-only). This is unfortunately very difficult problem, for lots of different reasons. If programmatic static image generation is your top requirement for you, my best suggestion currently is to look at other libraries.

Thanks,

Bryan

On Sep 7, 2016, at 9:03 AM, Wojciech Askuntowicz [email protected] wrote:

Hi,

I am generating graph by embed.file_html and I am trying to get plot image in png. I know it is possible by clicking save button from tools but I want to make it using just scripts in python. Do you have any idea how can I make it?

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/80339734-455b-4969-9ea1-7e7329b25f3f%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/038E9FB0-25BA-4DAC-8F2A-8E22D367DF4C%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

This is a potentially useful stopgap, but please be aware that PhantomJS does not support all the features that Bokeh relies on, and there are some things that it simply is incapable of rendering.

Thanks,

Bryan

···

On Sep 7, 2016, at 11:43 AM, Charles Morton <[email protected]> wrote:

I was able to programmatically generate PNGs from Bokeh HTML files using phantom.js (http://phantomjs.org/\) and the attached JS code that I found somewhere (probably on stackoverflow). I have python script that generates the html file using Bokeh then a separate python script that makes a subprocess call like the following:

phantom.js.exe report.js file:///D:/temp/input.html D:/temp/output.png

The three slashes seems weird to me but I have a comment in my code that "PhantomJS needs the full URL file path and/or maybe that is just a windows thing.

Charles

If the report.js file doesn't attach, here are the contents:
"use strict";
var page = require('webpage').create(),
    system = require('system'),
    address, output, size;

address = system.args[1];
output = system.args[2];
var width = 900
var height = 400
page.viewportSize = { width: width, height: height };
page.clipRect = { top: 30, left: 10, width: width-30, height: height-35 };

page.open(address, function (status) {
    if (status !== 'success') {
        console.log('Unable to load the address!');
        phantom.exit(1);
    } else {
        window.setTimeout(function () {
            page.render(output);
            phantom.exit();
        }, 1000);
    }
});

On Wed, Sep 7, 2016 at 7:57 AM, Bryan Van de Ven <[email protected]> wrote:
This is not currently possible, unfortunately. There is a long standing open issue you can follow for progress and discussion:

        Headless static (svg, png) image generation · Issue #538 · bokeh/bokeh · GitHub

There is a potentially promising avenue involving the headless Chrome project, but it would be Linux-only to start (since headless Chrome is currently Linux-only). This is unfortunately very difficult problem, for lots of different reasons. If programmatic static image generation is your top requirement for you, my best suggestion currently is to look at other libraries.

Thanks,

Bryan

> On Sep 7, 2016, at 9:03 AM, Wojciech Askuntowicz <[email protected]> wrote:
>
> Hi,
>
> I am generating graph by embed.file_html and I am trying to get plot image in png. I know it is possible by clicking save button from tools but I want to make it using just scripts in python. Do you have any idea how can I make it?
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/80339734-455b-4969-9ea1-7e7329b25f3f%40continuum.io\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/038E9FB0-25BA-4DAC-8F2A-8E22D367DF4C%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAGy%2B8A8voWUeXp%2BeKdB-HEe3L-Re18PMUtjZv14%3DyfzMy2qAUg%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
<report.js>