StanAngeloff / compass-magick

Dynamic image generation for Compass using ChunkyPNG/PhantomJS.
http://StanAngeloff.github.com/compass-magick/
Other
157 stars 4 forks source link

Phantomjs Error: undefined:2 TypeError: Result of expression 'phantom.state' [undefined] is not an object. #12

Closed pietschy closed 13 years ago

pietschy commented 13 years ago

Howdy,

Just installed phantomjs as per the instructions (also tried using brew but get the same thing).

When running compass compile the Phantomjs icon appears in my dock but I get the following message undefined:2 TypeError: Result of expression 'phantom.state' [undefined] is not an object and it just hangs there. Doing a ctrl-c kills it and the script then complains about the missing temp image.

Any ideas?

StanAngeloff commented 13 years ago

Are you actually able to run a Phantom script from the command line? There are examples on the PhantomJS website, try one that renders a PNG?

pietschy commented 13 years ago

Yep. I just tried the rasterise.js example and it worked fine.

StanAngeloff commented 13 years ago

It's been a rather long and exhausting day, sorry I couldn't get back to you earlier.

Could you please gist the smallest possible code that produces this error? I'd be grateful if you could also share Ruby, gem and PhantomJS versions.

pietschy commented 13 years ago

That's fine. It's open source (c:

$ phantomjs --version 1.2.0 (development) $ compass --version Compass 0.11.beta.7 $ gem list compass-magick compass-magick (0.1.4)

I've created a project from scratch and set screen.scss to the following: @import "compass";

body { @include background(magic-sprite('styln/highlight-glow', magick-phantom(320, 200, // Quotes are required for complex expressions $background-image: '-webkit-gradient(linear, left top, left bottom, from(#00abeb), to(#fff), color-stop(0.5, #fff), color-stop(0.5, #66cc00))', // Units and lists do not require quotes $border-radius: 10px, $box-shadow: 0px 10px 4px 2px rgba(0, 0, 0, 0.25) ) ) top center); }

And I'm getting the same error.

I'm happy to poke around and do some testing. I'm using a gem currently but I presume I can just install the code under extensions dir in my project..?

scottdavis commented 13 years ago

i know this is unrelated but you are using an old beta version of compass you may want to update to the latest non beta

pietschy commented 13 years ago

Cool, thanks. I've upgraded.

StanAngeloff commented 13 years ago

OK, looks like PhantomJS included a whole new set of APIs in 1.2 which is what is causing the scripts to no longer work. Try compiling from the 1.1 branch and copy the executable to a different location (so you can keep 1.2 if you need it for something else). Then in your config.rb file add a new configuration option:

phantom_executable = '/path/to/new/phantomjs'

This should do the trick.

BTW, why are you reverting to PhantomJS? If you are looking for speed and don't mind compiling some native binaries, check out compass-canvas.

pietschy commented 13 years ago

I'd just got around to trying it out since I was thinking of trying to create a plugin to render svg.

compass-canvas looks cool. I'll have a look.

StanAngeloff commented 13 years ago

compass-canvas will get an SVG path renderer soon.

Closing this issue for now.