StanAngeloff / compass-magick

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

Error: The number of pixels does not match the canvas dimensions #13

Open pietschy opened 12 years ago

pietschy commented 12 years ago

Hi there,

I'm getting an issue when using a computed value for the width of my canvas. The following snippet is producing the error.

$w: $side-gutter-width + span($left-sidebar-columms);
$h: 10px;
@include background($content-background-color magick-sprite('yvt/sidebar',
    magick-canvas($w, $h,
        magick-fill($sidebar-background-color)
        magick-fill($sidebar-border-color, $w - 1, 0, $w, $h)
    )
) top left repeat-y);

If it put a line in like debug: $w; then my css has a the line debug: 245px;

If I replace my declaration of $w with $w: 245px then it works as expected.

Any ideas?

Here's the stack trace.

RuntimeError on line ["174"] of /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb: The number of pixels does not match the canvas dimensions.
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb:174:in `encode_png_image_without_interlacing'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb:161:in `encode_png_pixelstream'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb:85:in `to_datastream'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb:35:in `write'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb:43:in `block in save'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb:43:in `open'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb:43:in `save'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-magick-0.1.4/lib/magick/functions/sprites.rb:23:in `magick_sprite'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/script/funcall.rb:88:in `_perform'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/script/node.rb:40:in `perform'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/script/list.rb:69:in `block in _perform'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/script/list.rb:69:in `map'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/script/list.rb:69:in `_perform'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/script/node.rb:40:in `perform'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:189:in `block in visit_mixin'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:185:in `each'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:185:in `inject'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:185:in `visit_mixin'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `visit'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:18:in `visit'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `map'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `visit_children'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:39:in `with_environment'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:26:in `visit_children'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `block in visit'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:234:in `visit_rule'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `visit'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:18:in `visit'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `map'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `visit_children'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:39:in `with_environment'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:26:in `visit_children'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `block in visit'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:234:in `visit_rule'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `visit'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:18:in `visit'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:144:in `block in visit_import'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:144:in `map'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:144:in `visit_import'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `visit'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:18:in `visit'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:144:in `block in visit_import'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:144:in `map'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:144:in `visit_import'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `visit'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:18:in `visit'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `map'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:53:in `visit_children'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:39:in `with_environment'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:26:in `visit_children'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `block in visit'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:47:in `visit_root'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/base.rb:37:in `visit'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:18:in `visit'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/visitors/perform.rb:7:in `visit'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/tree/root_node.rb:20:in `render'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/engine.rb:300:in `_render'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/sass-3.1.10/lib/sass/engine.rb:247:in `render'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/lib/compass/compiler.rb:136:in `block (2 levels) in compile'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/lib/compass/compiler.rb:122:in `timed'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/lib/compass/compiler.rb:135:in `block in compile'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/lib/compass/logger.rb:45:in `red'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/lib/compass/compiler.rb:134:in `compile'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/lib/compass/compiler.rb:114:in `compile_if_required'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/lib/compass/compiler.rb:99:in `block (2 levels) in run'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/lib/compass/compiler.rb:97:in `each'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/lib/compass/compiler.rb:97:in `block in run'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/lib/compass/compiler.rb:122:in `timed'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/lib/compass/compiler.rb:96:in `run'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/lib/compass/commands/update_project.rb:37:in `perform'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/lib/compass/commands/base.rb:18:in `execute'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/lib/compass/commands/project_base.rb:19:in `execute'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/lib/compass/exec/sub_command_ui.rb:43:in `perform!'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/lib/compass/exec/sub_command_ui.rb:15:in `run!'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/bin/compass:25:in `block in <top (required)>'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/bin/compass:39:in `call'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/gems/compass-0.11.6/bin/compass:39:in `<top (required)>'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/bin/compass:19:in `load'
  /Users/andrew/.rvm/gems/ruby-1.9.2-p136/bin/compass:19:in `<main>'
StanAngeloff commented 12 years ago

As soon as I get to a computer I will try your snippet. I suspect it may have something to do with the width of the gradient -- when the size is below 10px, magick would usually barf.