piqnt / svgexport

SVG to PNG/JPEG command-line tool and Node.js module
927 stars 85 forks source link

Move to phantomjs 2.0 #13

Closed hans-t closed 8 years ago

hans-t commented 9 years ago

Hi, is there any plan to upgrade the phantomjs used by svgexport to version 2?

shakiba commented 9 years ago

Hi @hanstzalora, it can be upgraded when phantomjs package for node.js is upgraded. Feel free to submit a pull request when it is ready.

hans-t commented 9 years ago

If you want to use phantomjs2 binary, do the following:

  1. Replace phantomjs binary in <svgexport dir>/node_modules/phantomjs/lib/phantom/bin with phantomjs2 binary. (I got the phantomjs2 binary by building it from source in Ubuntu 14.04. I believe npm doesn't have working phantomjs2 yet).
  2. In render.js, change these 2 lines: phantom.args.length !== 1 ---> system.args.length !== 2 phantom.args[0] ---> system.args[1]

That's it.

dan335 commented 9 years ago

Made a fork with phantomjs2 from https://github.com/Lochlan/phantomjs2

https://github.com/dan335/svgexport

Works on mac and ubuntu 14.04

shakiba commented 9 years ago

@dan335 Thanks, but does it works better with phantomjs2?

dan335 commented 9 years ago

The phantomjs version that svgexport depends on didn't work for me on mac. It works after switching to phantomjs2. Not sure if it works any better.

shakiba commented 9 years ago

@dan335 I see, thanks. I have used svgexport on mac before, if you remember the issue or can reproduce it please report it, I will try to fix it with phantomjs1. I'm interested in using phantomjs2 too, but I'm waiting to make sure it is stable.

NaxYo commented 8 years ago

Hey, I'm about to open a new issue, but I think it is more related to phantomjs than this module: applying positive saturation to an image filter (lets say 1.6 or 160%) make it fails (no image rendered).

@dan335 , @hanstzalora and anyone who have tried phantomjs2 instead, can you please tell me if phantomjs2 solve the issue?

@shakiba do you think there is something that we can do on svgexport module to fix the issue?

Input example: Original SVG Output example: svgexport result SVG: http://23.20.138.218:8082/test/input.svg

Thanks!

shakiba commented 8 years ago

saturate: adjusts the saturation of all RGB color channels (the alpha channel is not affected). The permitted value according to the specification is 0-1, but many browsers accept higher values >1 to allow over-saturation. —webplatform.org

@NaxYo It seems that phantomjs-1 (at least) doesn't support over-saturation, I don't know about v2.

NaxYo commented 8 years ago

If someone face this "positive saturation problem" I have found a workaround by using a colorMatrix instead of saturate. In chrome and phantom it render really similar, I haven't made the full calculation, but I'm pretty sure we can get the same result.

<feColorMatrix type="matrix" 
    values="1.7  -0.3 -0.3 0 0
            -0.3  1.7 -0.3 0 0
            -0.3 -0.3  1.7 0 0
             0     0    0  1 0">
</feColorMatrix>

Is equivalent to

<feColorMatrix type="saturate" values="2"></feColorMatrix>

Applying cross-multiplication we can get any other value from saturate = 1 -> matrix center = 1, sides = 0; to saturate 2 => matrix center = 1.7, sides = -.3

Hopes it helps someone!

davemackintosh commented 8 years ago

Should be closed now #27 and #28 are closed

shakiba commented 8 years ago

@davemackintosh Yes, thanks for your help, and everyone else!

svgexport v0.3.0 now depends on phantomjs-prebuild which uses phantomjs v2.